fork is ok but forked process could not be killed.
--- 2009年7月28日 星期二,Xiao Yafeng <[email protected]> 寫道﹕
寄件人: Xiao Yafeng <[email protected]>
主題: Re: fork and kill process
收件人: "Aclhk Aclhk" <[email protected]>
日期: 2009年7月28日,星期二,上午8:39
Using fork function on window is no problem. Below code spawns 10 processes and
print in turn:
use strict;
use warnings;
my $max_process = 10;
my $processes = 0;
for my $count (1..100){
wait if $processes >= $max_process;
do{print $count."\n";exit} unless my $pid = fork;
$processes ++;
}
I roughly remember $pid of child process may not be zero on window. below one
line could prove whether my guess is right or not:
perl -e 'if($pid = fork){print "parent pid is".$pid."\n";}else{print "child pid
is".$pid,"\n";}'
2009/7/28 Aclhk Aclhk <[email protected]>
i am new to writing perl in windows. I would like to achieve the same result
from the following code:
$pid = fork();
defined $pid or die "fork($pid)\n";
if($pid == 0)
{
exec("dir");
}
sleep(10);
kill("TERM" => $pid);
I would to spawn a process and kill it (including the child process) at later
time.
Pls advise what code should be in windows environment. someone suggested
win32::job but i failed to write a success code.
Yahoo!香港提供網上安全攻略,教你如何防範黑客!了解更多
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Yahoo!香港提供網上安全攻略,教你如何防範黑客! 請前往 http://hk.promo.yahoo.com/security/ 了解更多!_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs