On Oct 21, Christopher Spears said:
I've been working on a script that will allow me to kill a certain program using the program's PID.
sub findPID { if (my $PID = `pgrep PROGRAM`) { return $PID; } else { return 0; } }
pgrep CAN return more than one PID, but it also returns them with newlines at the end.
sub findPID { if (my @results = `pgrep PROGRAM`) { chomp @results; return wantarray ? @results : $results[0]; } else { return } } Then you can do: my @pids = findPID(); # or my $pid = findPID();
kill 1,$fPID;
That's sending it a HUP signal. Do you expect PROGRAM to die when it receives the HUP signal?
kill 9,$fPID1;
NOW it should die, since 9 is KILL. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://www.perlmonks.org/ % have long ago been overpaid? http://princeton.pm.org/ % -- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>