File: zombie.pl

package info (click to toggle)
hobbit-plugins 20190129
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 588 kB
  • sloc: perl: 3,273; sh: 84; makefile: 22
file content (22 lines) | stat: -rwxr-xr-x 458 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
20
21
22
#!/usr/bin/perl -w

# Script to generate a zombie process to test misc.d/zombies.
# Author: Axel Beckert <abe@debian.org>

use 5.010;

my $pid = fork;

if ($pid) {
    say "PARENT: Parent = $$. Child = $pid";
    # Parent stops itself
    kill(19, $$);
    say "PARENT: continued...";
    exit 0;
} elsif (defined $pid and $pid == 0) {
    say "CHILD: Child = $$";
    sleep 1;
    say "CHILD: Back from sleep, exiting"
} else {
    say "FORK failed: $!";
}