fork |
使用fork()係統調用fork一個新進程。任何共享的套接字或文件句柄是重複整個過程。你必須確保你等待你的子進程,以防止形成“僵屍”進程。
undef - 開一個fork進程失敗
返回子進程ID-如果父進程成功 ,0 - 如果子進程成功
以下是用法...
#!/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 #by www.gitbook.net This is parent process and child ID is 16417 Parent process is existing This is child process Chile process is existing