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