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;

In reply to Re: Process termination by aplonis
in thread Process termination by sh1tn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.