【发布时间】:2015-11-02 21:23:56
【问题描述】:
所以我知道 Windows 不支持 Unix fork-exec 模型,而是生成进程。然而,Strawberry Perl 的 fork 仿真会产生具有负 PID 的子代。这些 PID 似乎是一致的,但我不明白为什么它们是负数,或者实际上,Perl 是如何模拟 Unix fork 的。
use strict;
use warnings;
my $cpid = fork();
if ($cpid == 0) {
printf "%s\n", "I'm the child, pid is $$";
} else {
printf "%s\n", "I'm the parent, pid is $$, cpid is $cpid";
}
这会产生类似于:
I'm the parent, pid is 3428, cpid is -2600
I'm the child, pid is -2600
【问题讨论】:
标签: windows perl fork strawberry-perl