我已经写了下面这段代码来测试孩子和父母之间的信号。理想情况下,当孩子给父母提供一个SIGINT时,父母应该返回新的迭代并等待用户输入。这是我在perl 5.8中观察到的,但是在perl 5.6.1(我被要求使用)中父母实际上是“被杀死”的。没有下一个迭代。perl - 子进程发信号父母
my $parent_pid = $$;
$pid = fork();
if($pid == 0)
{
print "child started\n";
kill 2, $parent_pid;
}
else
{
while(1)
{
eval
{
$SIG{INT} = sub{die "GOTCHA";};
print 'inside parent'."\n";
$a = <>;
};
if([email protected])
{
print "got the signal!!!!\[email protected]\n";
next;
}
}
}
有人请给出一个解决这个问题或其他方式的信号,以便它进入新的迭代。
Sry基因,不能重现它。 – int2000
Windows还是不行? – ikegami
@ikegami windows它是 –