]>
Commit | Line | Data |
---|---|---|
d0ab7780 UD |
1 | #include <stdio.h> |
2 | #include <unistd.h> | |
3 | #include <error.h> | |
4 | #include <errno.h> | |
464d646f | 5 | #include <sys/wait.h> |
d0ab7780 UD |
6 | |
7 | void noop (void); | |
8 | ||
9 | int | |
10 | main (void) | |
11 | { | |
12 | int pid; | |
13 | ||
14 | printf ("Before vfork\n"); | |
15 | fflush (stdout); | |
16 | pid = vfork (); | |
17 | if (pid == 0) | |
18 | { | |
19 | /* This will clobber the return pc from vfork in the parent on | |
20 | machines where it is stored on the stack, if vfork wasn't | |
21 | implemented correctly, */ | |
22 | noop (); | |
23 | _exit (2); | |
24 | } | |
25 | else if (pid < 0) | |
26 | error (1, errno, "vfork"); | |
27 | printf ("After vfork (parent)\n"); | |
28 | wait (0); | |
29 | exit (0); | |
30 | } | |
31 | ||
32 | void | |
33 | noop () | |
34 | { | |
35 | } |