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");
23 static void exit_cb(struct process *process)
25 struct test *test = process->data;
28 test->exit_status = process->exit_status;
30 test->stdout_len = process->stdout_len;
31 test->stdout_buf = talloc_steal(test, process->stdout_buf);
34 int main(int argc, char **argv)
36 struct waitset *waitset;
37 struct process *process;
38 const char *child_argv[3];
41 if (argc == 2 && !strcmp(argv[1], "child"))
44 test = talloc_zero(NULL, struct test);
46 waitset = waitset_create(test);
48 process_init(test, waitset, false);
50 child_argv[0] = argv[0];
51 child_argv[1] = "child";
54 process = process_create(test);
55 process->path = child_argv[0];
56 process->argv = child_argv;
57 process->keep_stdout = true;
58 process->exit_cb = exit_cb;
61 process_run_async(process);
70 assert(WIFEXITED(test->exit_status));
71 assert(WEXITSTATUS(test->exit_status) == 42);
72 assert(test->stdout_len == strlen("forty two\n"));
73 assert(test->stdout_buf);
74 assert(!memcmp(test->stdout_buf, "forty two\n", strlen("forty two\n")));