-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkiller
More file actions
42 lines (37 loc) · 796 Bytes
/
Copy pathkiller
File metadata and controls
42 lines (37 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
#oxr 2026
# Gestiona procesos si existen, no da error
#
#\\r killer -t|-s|-c|-k|-señal pid|nombre ...
#
# '-t' term
# '-c' cont
# '-s' stop
# '-k' kill
# '-*' señal
#
#
#\\r
# ⧵∕
[ $include_ctl ] || . include ; include isnum
killer(){ # la funcion esta derivada a la salida: killer(){ ... } 1>/dev/null
[ $# -gt 0 ] || { infsh $code/killer 3 10 >&2 ; return ;}
local o="-TERM" n=false
case "$1" in
-t) O=-TERM ; shift ;;
-s) o=-STOP ; shift ;;
-c) o=-CONT ; shift ;;
-k) o=-KILL ; shift ;;
-*) o=-$1 ; shift ;;
*) return ;;
esac
while [ $# -gt 0 ] ; do
echo killer:"'$@'"
isnum $1 && { [ -e /proc/$1 ] || return 1 ;} || { pidof $1 && n=true || return 1 ;}
$n && pkill $o $1 || kill $o $1
n=false
shift
done
} 1>/dev/null
[ ${0##*/} != killer ] || killer "$@"
#