debuggers.hg

view tools/libaio/harness/cases/12.t @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 /* 12.t
2 - ioctx access across fork() (12.t)
3 */
4 #include <sys/types.h>
5 #include <sys/wait.h>
6 #include <unistd.h>
7 #include <signal.h>
9 #include "aio_setup.h"
11 void test_child(void)
12 {
13 int res;
14 res = attempt_io_submit(io_ctx, 0, NULL, -EINVAL);
15 fflush(stdout);
16 _exit(res);
17 }
19 int test_main(void)
20 {
21 int res, status;
22 pid_t pid;
24 if (attempt_io_submit(io_ctx, 0, NULL, 0))
25 return 1;
27 sigblock(sigmask(SIGCHLD) | siggetmask());
28 fflush(NULL);
29 pid = fork(); assert(pid != -1);
31 if (pid == 0)
32 test_child();
34 res = waitpid(pid, &status, 0);
36 if (WIFEXITED(status)) {
37 int failed = (WEXITSTATUS(status) != 0);
38 printf("child exited with status %d%s\n", WEXITSTATUS(status),
39 failed ? " -- FAILED" : "");
40 return failed;
41 }
43 /* anything else: failed */
44 if (WIFSIGNALED(status))
45 printf("child killed by signal %d -- FAILED.\n",
46 WTERMSIG(status));
48 return 1;
49 }