I used wait. I knew which child exited. All that the WNOHANG flag could have added is cause to tie up the CPU in a tight loop. And getting the right value would give you reason to load POSIX, which both slows down the code and makes it less portable!
And for the record I was not telling people to use wait instead of waitpid. I was telling you that you are wrong when you say that wait is deprecated and particularly dangerous.
Ironically not only is wait not dangerous when used correctly, but your advice all presumes that the programmer will use signals. In fact cautious programmers have read the documentation, see the warnings, and avoid signals in Perl. Your giving any advice based on your theories of how to write good signals is encouraging a practice that is dangerous in Perl.
Not only that, but the fact that you get a more complex signal handler can cause its own problems. perlipc offers two signal handlers. You and Stevens blast the one that uses wait based on how a safe handler in C should be written. But it is unclear that the waitpid handler is any better. It is more complex, you spend more time in the handler (when any signal will crash you), and the fact that you are assigning to a hash means that eventually you may wind up having a malloc() happen behind your back which would probably cause you to dump core!
Personally I just skip down to the big WARNING section, take that to heart and avoid both of them!
In reply to RE (tilly) 6: For all your forking needs..
by tilly
in thread For all your forking needs..
by reyjrar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |