Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL fork Function
Syntax
Definition and Usage
Forks a new process using the fork( ) system call. Any shared sockets or filehandles are
duplicated across processes. You must ensure that you wait on your children to prevent
"zombie" processes from forming.
Return Value
Example
Following are the usage...
#!/usr/bin/perl
$pid = fork();
if( $pid == 0 ){
print "This is child process\n";
print "Chile process is existing\n";
exit 0;
}
print "This is parent process and child ID is $pid\n";
print "Parent process is existing\n";
exit 0;
#This will produce following result
This is parent process and child ID is 16417
Parent process is existing
This is child process
Chile process is existing
|
|

|
|
|