programming-examples/perl/SystemFunction/To retrieve the process ID for the parent process for your program, call the function getppid.pl
2019-11-15 12:59:38 +01:00

12 lines
293 B
Perl

# The syntax of the getppid function is parentid = getppid();
# A program that calls fork and getppid.
#!/usr/local/bin/perl
$otherid = fork();
if ($otherid == 0) {
# this is the child; retrieve parent ID
$otherid = getppid();
} else {
# this is the parent
}