To retrieve the process ID for the parent process for your program, call the function getppid. : fork « System Functions « Perl






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 
} 

   
    
    
    
    
    
  








Related examples in the same category

1.fork returns the child's process ID
2.Using fork and pipe.
3.Using fork to create child processes
4.Distinguish between the parent and child processes