6 #include <process/process.h>
7 #include <waiter/waiter.h>
8 #include <talloc/talloc.h>
10 static int do_child(void)
12 printf("forty two\n");
16 int main(int argc, char **argv)
18 struct waitset *waitset;
19 struct process *process;
20 const char *child_argv[3];
23 if (argc == 2 && !strcmp(argv[1], "child"))
26 ctx = talloc_new(NULL);
28 waitset = waitset_create(ctx);
30 process_init(ctx, waitset, false);
32 child_argv[0] = argv[0];
33 child_argv[1] = "child";
36 process = process_create(ctx);
37 process->path = child_argv[0];
38 process->argv = child_argv;
39 process->keep_stdout = true;
41 printf("not this stdout\n");
43 process_run_sync(process);
45 assert(WIFEXITED(process->exit_status));
46 assert(WEXITSTATUS(process->exit_status) == 42);
48 assert(process->stdout_len == strlen("forty two\n"));
49 assert(!memcmp(process->stdout_buf, "forty two\n",
50 process->stdout_len));