所以我明白,Windows不支持Unix fork-exec模型,而是產生進程。但是,Strawberry Perl的fork仿真產生負PID的兒童。這些PID似乎是一致的,但我不明白爲什麼它們是否定的,或者真的,Perl如何模擬Unix分支。草莓Perl負面孩子PID分叉時
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
「您應該將正PID解釋爲原始線程的實際PID,否定PID實際上是線程ID」這是否記錄在任何位置? – ThisSuitIsBlackNot
我讀了perlfork,不知道負數是從哪裏來的,只有那些神祕的事情發生在用'wait',如果你得到一個僞pid爲-1 –