Hi ,
I am trying to execute :
system("while true; do echo aabbcc >> $temp_file; sleep 2; done &"); system("tail -f $temp_file >> $file &");
And then catch the events with the AnyEvent framework. It works but my system calls creates 2 zombie process when I kill my main program. The while and tail -f commands are still executing because the system calls are executing in an other group than my main script. How can I fix this ?
Thank you for your help. Regards
I finally got it working by using :
$childPid = open SON, "-|"; sub sigtrap() { print "\n"; print("------ Killing all childrens then exeting ... --- +---\n"); if(defined($childPid) && ! ($childPid == 0)){ killfam 'KILL', ($childPid); } print "\n"; print "Exiting ... \n"; exit(1); } if ($childPid) { #parent system("while true; do echo aabbcc >> $temp_file; sleep 2; done"); }else { print "[$$]: Child...\n"; system("tail -f $temp_file >> $file &"); exit(0); }
I finally understood that i needed to use a different process for each infinite running task and that if I wanted to do this in a non blocking mode I should do it on a fork.
Thank you all for your help
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |