Debian Codegraph @

debian/src/initscripts/etc/init.d/killprocs

raw
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: killprocs
4 # Required-Start: $local_fs
5 # Required-Stop:
6 # Default-Start: 1
7 # Default-Stop:
8 # Short-Description: executed by init(8) upon entering runlevel 1 (single).
9 ### END INIT INFO
10
11 PATH=/usr/sbin:/usr/bin:/sbin:/bin
12
13 . /lib/lsb/init-functions
14
15 do_start() {
16 # Kill all processes.
17 log_action_begin_msg "Asking all remaining processes to terminate"
18 killall5 -15 # SIGTERM
19 log_action_end_msg 0
20 alldead=""
21 for seq in 1 2 3 4 5 6 7 8 9 10; do
22 # use SIGCONT/signal 18 to check if there are
23 # processes left. No need to check the exit code
24 # value, because either killall5 work and it make
25 # sense to wait for processes to die, or it fail and
26 # there is nothing to wait for.
27
28 if killall5 -18; then
29 :
30 else
31 alldead=1
32 break
33 fi
34
35 sleep 1
36 done
37 if [ -z "$alldead" ]; then
38 log_action_begin_msg "Killing all remaining processes"
39 killall5 -9 # SIGKILL
40 log_action_end_msg 1
41 else
42 log_action_begin_msg "All processes ended within $seq seconds."
43 log_action_end_msg 0
44 fi
45 }
46
47 case "$1" in
48 start)
49 do_start
50 ;;
51 restart | reload | force-reload)
52 echo "Error: argument '$1' not supported" >&2
53 exit 3
54 ;;
55 stop | status)
56 # No-op
57 ;;
58 *)
59 echo "Usage: $0 start|stop" >&2
60 exit 3
61 ;;
62 esac