7 #include <process/process.h>
8 #include <waiter/waiter.h>
9 #include <talloc/talloc.h>
11 static int do_child(int ppid)
15 printf("forty two\n");
19 int main(int argc, char **argv)
21 struct waitset *waitset;
22 struct process *process;
23 const char *child_argv[4];
26 if (argc == 3 && !strcmp(argv[1], "child"))
27 return do_child(atoi(argv[2]));
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";
37 child_argv[2] = talloc_asprintf(ctx, "%d", getpid());
40 process = process_create(ctx);
41 process->path = child_argv[0];
42 process->argv = child_argv;
43 process->keep_stdout = 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));