File: zombie.pl

package info (click to toggle)
newpid 10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 100 kB
  • sloc: ansic: 210; makefile: 39; sh: 13; perl: 12
file content (19 lines) | stat: -rwxr-xr-x 424 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl

# This script forks twice, and the middle process exits immediately. The third
# process will then gets pid 1 as parent, and exit later. At that point, pid 1
# receives a SIGCHLD signal. The first process keeps running so we can actually
# observe this effect.

if (fork == 0) {
	if (fork == 0) {
		sleep 1;
		exit 1;
	} else {
		exit 2;
	}
} else {
	sleep 2;
	system "ps -opid,ppid,command xf";
	exit 0;
}