Commits

Cameron Simpson committed 4d1b9a2

killpidfile: move main logic into killpids, recite running process args in recite mode

Comments (0)

Files changed (1)

 trace=set-x
 sigopt=-TERM	# use USR1 if aiming at fetchmail daemon
 dounlink=
-dowait=
-killafter=
+wopt=
+Wopt=
 
 cmd=$0
 usage="Usage: $cmd [-d pidfiledir] [-u] [-w] [-W seconds] [-signal] pidfiles...
   case "$1" in
     -d)	VARRUN=$2; shift ;;
     -u)	dounlink=1 ;;
-    -w)	dowait=1 ;;
-    -W)	killafter=$2; shift ;;
+    -w)	wopt=$1 ;;
+    -W)	Wopt="-W $2" ;;
     -[0-9]* | -[A-Z]* )
 	sigopt=$1
 	;;
       while read pid
       do  if kill -0 "$pid" 2>/dev/null
           then
-            echo "$pidfile	$pid"
+            echo "$pidfile	$pid" `ps -o args -p "$pid" 2>/dev/null | sed 1d`
           else
             echo "$pidfile	$pid MISSING"
             ok=
   [ $dounlink ] && rm "$pidfile"
 done
 
-pass=1
-while [ -n "$pids" ]
-do
-  livepids=
-  for pid in $pids
-  do $trace kill $sigopt "$pid" && livepids="$livepids $pid"
-  done
-
-  [ -n "$livepids" ] || break
-  [ $dowait ] || break
-
-  pids=$livepids
-  sleep 1
-
-  sigopt=-0
-  pass=`expr "$pass" + 1`
-  [ -n "$killafter" ] && [ "$pass" -ge "$killafter" ] && sigopt=-9
-done
+exec killpids $wopt $Wopt $sigopt -- "$@"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.