3 # Test that getppid() follows UNIX semantics: when the parent process
4 # dies, the child is reparented to the init process (pid 1).
15 for my $syscall (qw(pipe fork waitpid getppid)) {
16 if (!$Config{"d_$syscall"}) {
17 print "1..0 # Skip: no $syscall\n";
24 pipe my ($r, $w) or die "pipe: $!\n";
25 my $pid = fork; defined $pid or die "fork: $!\n";
30 waitpid($pid, 0) == $pid or die "waitpid: $!\n";
36 my $pid2 = fork; defined $pid2 or die "fork: $!\n";
43 my $ppid1 = getppid();
44 print $w "not " if $ppid1 <= 1;
45 print $w "ok 1 # ppid1=$ppid1\n";
47 my $ppid2 = getppid();
48 print $w "not " if $ppid1 == $ppid2;
49 print $w "ok 2 # ppid2=$ppid2, ppid1!=ppid2\n";
50 print $w "not " if $ppid2 != 1;
51 print $w "ok 3 # ppid2=1\n";