I recently gave some advice about negating the PID of process to kill its children: Re: open (to read) and kill a pipe to a pipe. According to the perldoc for kill, I was wrong. And the OP in that thread reported that doing it the way I suggested didn't work but trying per the doc did work, on Windows no less. But the "wrong" way seems to work on *nix too. Anyone know why?
(Updated title to include "kill.")system("sleep 1234 &"); my ( $pid ) = qx{ pgrep -f sleep | xargs ps | grep "1234" | grep -v grep } =~ /(\d+)/; print "Check me\n\tps $pid\n"; # kill 9 => $$; # Leaves sleep process alive. # kill -9 => $$; # Kills sleep process. kill 9 => -$$; # Also kills sleep process.
In reply to Kill negated PIDs v negated SIGs by Your Mother
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |