6 #include <process/process.h>
7 #include <waiter/waiter.h>
8 #include <talloc/talloc.h>
10 static int do_child(void)
12 fprintf(stderr, "forty ");
14 fprintf(stdout, "two\n");
19 int main(int argc, char **argv)
21 struct waitset *waitset;
22 struct process *process;
23 const char *child_argv[3];
26 if (argc == 2 && !strcmp(argv[1], "child"))
29 ctx = talloc_new(NULL);
31 waitset = waitset_create(ctx);
33 process_init(ctx, waitset, false);
35 child_argv[0] = argv[0];
36 child_argv[1] = "child";
39 process = process_create(ctx);
40 process->path = child_argv[0];
41 process->argv = child_argv;
42 process->keep_stdout = true;
43 process->add_stderr = true;
45 process_run_sync(process);
47 assert(WIFEXITED(process->exit_status));
48 assert(WEXITSTATUS(process->exit_status) == 42);
50 assert(process->stdout_len == strlen("forty two\n"));
51 assert(!memcmp(process->stdout_buf, "forty two\n",
52 process->stdout_len));