题
我的问题与在Perl代码中使用 fork()
有关。
我希望fork一个新进程并捕获它的PID并将其返回给被调用程序。在Perl中是否有一些命令可以实现这一点?
解决方案
my $pid = fork();
if ($pid == 0)
{
# We are the child.
}
elsif defined($pid)
{
# We are the parent of child with PID=pid
}
else
{
# The fork failed
}
不隶属于 StackOverflow