aboutsummaryrefslogtreecommitdiff
path: root/posix/test-vfork.c
blob: 60abe0bcf71adc68ca4f7876c5e45fec19405bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <unistd.h>
#include <error.h>
#include <errno.h>

void noop (void);

int
main (void)
{
  int pid;

  printf ("Before vfork\n");
  fflush (stdout);
  pid = vfork ();
  if (pid == 0)
    {
      /* This will clobber the return pc from vfork in the parent on
	 machines where it is stored on the stack, if vfork wasn't
	 implemented correctly, */
      noop ();
      _exit (2);
    }
  else if (pid < 0)
    error (1, errno, "vfork");
  printf ("After vfork (parent)\n");
  wait (0);
  exit (0);
}

void
noop ()
{
}