in reply to Process termination
Tried and liked it, except for one little problem. Sometimes it would kill itself first, and being thus dead, fail to terminate its target file. This would happen in NetBSD because the arg also appeared in the list and sometimes ahead of the target file.
So I made a tiny change to exclude the kill script itself as shown below.
#!/usr/pkg/bin/perl -w my $prog = shift || die "no args!\n"; my @pids; open PH, "ps ax|" or die $!; while( <PH> ){ !/$0/ && /$prog/ || next; # <-- Change here. /^\s*(\d+)/ and push @pids, $1 } # Try gracefully first, then less so. kill 15, $_ for @pids; sleep 5; kill 2, $_ for @pids; sleep 5; kill 9, $_ for @pids;
|
|---|