I'm with
diotalevi on this one.
kill INT, $pid will send the INT signal to the process with $PID, regardless of whether or not said process is a child of the process sending the signal. However, if the sending process is not running as root, the chances of actually interrupting another process with this are lessened because i) there needs to be a process with $PID, which with current 32-bit process ID spaces tends to take a while and ii) said process needs to be running under the same UID as the sending process. However, it is still not a chance one should take in production environments. Hence:
To check whether your $PID is still the correct process, have a look at Proc::ProcessTable to browse throught the process table. This will give you a way to check whether process $PID is still the correct one:
use strict;
use Proc::ProcessTable;
my $table=Proc::ProcessTable->new;
my @procs=$table->table;
foreach $p ($table->table) {
if ($p->pid == $saved_pid) {
send_signal() if ($p->cmdline eq "expected command line");
}
}
#Warning: code is utterly untested and not the most efficient either.
CU
Robartes-
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.