There's more than one way to do things | |
PerlMonks |
Fork Wait and probably grandchildrenby Discordanian (Initiate) |
on Apr 05, 2005 at 15:02 UTC ( [id://445003]=perlquestion: print w/replies, xml ) | Need Help?? |
Discordanian has asked for the wisdom of the Perl Monks concerning the following question:
I'm having some difficulty with forking and waiting for my processes to finish. At first I inserted a big 'sleep' after my wait, but after fiddling with the source I was able to duplicate my issue in a much smaller snippet of code. Bear with me:
The contents of smoke.sh:
As you can see, smoke.sh is trivial, but it has pipes. The contents of smoke.txt is just a long text listing with smoke.pl being a line in there. When I run my app, smoke.sh runs, wait gets the returned children but I get several failures in the log. My theory is that smoke.sh returns before the piped grandchildren (I originally just had a cat without the pipes, but the error didn't occur). I also get the error if I put $syscmd = "cat smoke.txt |sort |uniq -c > $templog 2>&1"; directly. So how can I get around this? I do a fork call 11 times writing to 11 log files and then I'm grepping those log files for a certain result and I get errors and this is presumably because the app I'm calling forks a writing thread.
Any and all help is greatly appreciated.
Back to
Seekers of Perl Wisdom
|
|