]> git.ipfire.org Git - thirdparty/glibc.git/blame - posix/test-vfork.c
S390: Mark vx and vxe as important hwcap.
[thirdparty/glibc.git] / posix / test-vfork.c
CommitLineData
d0ab7780 1#include <stdio.h>
3e1f480e 2#include <stdlib.h>
d0ab7780
UD
3#include <unistd.h>
4#include <error.h>
5#include <errno.h>
464d646f 6#include <sys/wait.h>
d0ab7780 7
8f6a393e 8void __attribute_noinline__ noop (void);
d0ab7780 9
d48f4d53
UD
10#define NR 2 /* Exit code of the child. */
11
d0ab7780
UD
12int
13main (void)
14{
d48f4d53
UD
15 pid_t pid;
16 int status;
d0ab7780
UD
17
18 printf ("Before vfork\n");
19 fflush (stdout);
20 pid = vfork ();
21 if (pid == 0)
22 {
23 /* This will clobber the return pc from vfork in the parent on
24 machines where it is stored on the stack, if vfork wasn't
25 implemented correctly, */
26 noop ();
d48f4d53 27 _exit (NR);
d0ab7780
UD
28 }
29 else if (pid < 0)
30 error (1, errno, "vfork");
31 printf ("After vfork (parent)\n");
d48f4d53 32 if (waitpid (0, &status, 0) != pid
b1195070 33 || !WIFEXITED (status) || WEXITSTATUS (status) != NR)
d48f4d53 34 exit (1);
bf4de8f3
AJ
35
36 return 0;
d0ab7780
UD
37}
38
39void
60d2f8f3 40noop (void)
d0ab7780
UD
41{
42}