freebsd-ports/net-mgmt/net-snmp-devel/files/patch-local:fixproc
Jun Kuriyama de310693e8 - Upgrade to 5.2.2.
- Return more appropriate values for hrSWRunType (1)

PR:		ports/86572 (1)
Submitted by:	wollman (1)
2005-11-30 05:22:40 +00:00

90 lines
2.4 KiB
Text

--- local/fixproc.orig Wed May 25 01:23:54 2005
+++ local/fixproc Wed Nov 30 12:16:05 2005
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!%%PERL%%
#
# fixproc [-min n] [-max n] [-check | -kill | -restart | -exist | -fix] proc ...
#
@@ -131,7 +131,7 @@
use File::Temp qw(tempfile);
-$database_file = '/local/etc/fixproc.conf';
+$database_file = '%%PREFIX%%/etc/fixproc.conf';
$debug = 0; # specify debug level using -dN
# currently defined: -d1
@@ -157,6 +157,14 @@
$shell_header = "#!/bin/sh\n";
$shell_end_marker = 'shell_end_marker';
+open(command, "/bin/ps -p $$ |") || die "$0: can't run ps command\n";
+if (split(' ', <command>) > 4) {
+ $ps_opts = 'ax';
+} else {
+ $ps_opts = '-e';
+}
+close command;
+
&read_args();
&read_database();
# &dump_database(); # debug only
@@ -305,41 +313,47 @@
# first try kill
$! = $fixproc_error;
- open (COMMAND, "/bin/ps -e | /bin/grep $proc |")
+ open (COMMAND, "/bin/ps $ps_opts |")
|| die "$0: can't run ps-grep-awk command\n";
while (<COMMAND>)
{
- # match the first field of ps -e
+ if /$proc/ {
+ # match the first field of ps $ps_opts
$! = $fixproc_error;
- /^\s*(\d+)\s/ || die "$0: can't match ps -e output\n";
- system "kill $1";
+ /^\s*(\d+)\s/ || die "$0: can't match ps $ps_opts output\n";
+ kill 15, $1;
+ }
}
+ close COMMAND;
# if process still exist, try kill -9
sleep 2;
$! = $fixproc_error;
- open (COMMAND, "/bin/ps -e | /bin/grep $proc |")
+ open (COMMAND, "/bin/ps $ps_opts |")
|| die "$0: can't run ps-grep-awk command\n";
$second_kill_needed = 0;
while (<COMMAND>)
{
- # match the first field of ps -e
+ if /$proc/ {
+ # match the first field of ps $ps_opts
$! = $fixproc_error;
- /^\s*(\d+)\s/ || die "$0: can't match ps -e output\n";
- system "kill -9 $1";
+ /^\s*(\d+)\s/ || die "$0: can't match ps $ps_opts output\n";
+ kill 9, $1;
$second_kill_needed = 1;
}
+ close COMMAND;
return ($no_error) if ($second_kill_needed == 0);
# see if kill -9 worked
sleep 2;
$! = $fixproc_error;
- open (COMMAND, "/bin/ps -e | /bin/grep $proc |")
+ open (COMMAND, "/bin/ps $ps_opts |")
|| die "$0: can't run ps-grep-awk command\n";
while (<COMMAND>)
{ # a process still exist, return error
- return $cannot_kill_error;
+ return $cannot_kill_error if /$proc/;
}
+ close COMMAND;
return $no_error; # good, all dead
}