]> sourceware.org Git - glibc.git/blame - posix/test-vfork.c
(__libc_sa_len): Add some missing cases.
[glibc.git] / posix / test-vfork.c
CommitLineData
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
7void noop (void);
8
d48f4d53
UD
9#define NR 2 /* Exit code of the child. */
10
d0ab7780
UD
11int
12main (void)
13{
d48f4d53
UD
14 pid_t pid;
15 int status;
d0ab7780
UD
16
17 printf ("Before vfork\n");
18 fflush (stdout);
19 pid = vfork ();
20 if (pid == 0)
21 {
22 /* This will clobber the return pc from vfork in the parent on
23 machines where it is stored on the stack, if vfork wasn't
24 implemented correctly, */
25 noop ();
d48f4d53 26 _exit (NR);
d0ab7780
UD
27 }
28 else if (pid < 0)
29 error (1, errno, "vfork");
30 printf ("After vfork (parent)\n");
d48f4d53
UD
31 if (waitpid (0, &status, 0) != pid
32 || !WIFEXITED (status) || WEXITSTATUS (NR))
33 exit (1);
d0ab7780
UD
34 exit (0);
35}
36
37void
38noop ()
39{
40}
This page took 0.035466 seconds and 5 git commands to generate.