Mega Code Archive

 
Categories / Perl / System Functions
 

To retrieve the process ID for the parent process for your program, call the function getppid

# 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  }