summaryrefslogtreecommitdiff
path: root/beagle/debian-rfs/etc/init.d/killprocs
diff options
context:
space:
mode:
authorManuel Traut <manut@mecka.net>2011-04-29 09:09:27 +0200
committerManuel Traut <manut@mecka.net>2011-04-29 09:09:27 +0200
commit5238ad5a0c4a9e1c8cd036f5de4055e39bd71297 (patch)
tree4407c087b9fb5432b1dc11e70b52dacfa0b99feb /beagle/debian-rfs/etc/init.d/killprocs
parent60ead65c41afba7e6aa4bbcf507a1d52f7a8fe9f (diff)
added debootstrap stuff
Signed-off-by: Manuel Traut <manut@mecka.net>
Diffstat (limited to 'beagle/debian-rfs/etc/init.d/killprocs')
-rwxr-xr-xbeagle/debian-rfs/etc/init.d/killprocs62
1 files changed, 62 insertions, 0 deletions
diff --git a/beagle/debian-rfs/etc/init.d/killprocs b/beagle/debian-rfs/etc/init.d/killprocs
new file mode 100755
index 0000000..6cb5b91
--- /dev/null
+++ b/beagle/debian-rfs/etc/init.d/killprocs
@@ -0,0 +1,62 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: killprocs
+# Required-Start: $local_fs
+# Required-Stop:
+# Default-Start: 1
+# Default-Stop:
+# Short-Description: executed by init(8) upon entering runlevel 1 (single).
+### END INIT INFO
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+. /lib/lsb/init-functions
+
+do_start () {
+ # Kill all processes.
+ log_action_begin_msg "Asking all remaining processes to terminate"
+ killall5 -15 # SIGTERM
+ log_action_end_msg 0
+ alldead=""
+ for seq in 1 2 3 4 5 6 7 8 9 10; do
+ # use SIGCONT/signal 18 to check if there are
+ # processes left. No need to check the exit code
+ # value, because either killall5 work and it make
+ # sense to wait for processes to die, or it fail and
+ # there is nothing to wait for.
+
+ if killall5 -18 ; then
+ :
+ else
+ alldead=1
+ break
+ fi
+
+ sleep 1
+ done
+ if [ -z "$alldead" ] ; then
+ log_action_begin_msg "Killing all remaining processes"
+ killall5 -9 # SIGKILL
+ log_action_end_msg 1
+ else
+ log_action_begin_msg "All processes ended within $seq seconds."
+ log_action_end_msg 0
+ fi
+}
+
+case "$1" in
+ start)
+ do_start
+ ;;
+ restart|reload|force-reload)
+ echo "Error: argument '$1' not supported" >&2
+ exit 3
+ ;;
+ stop)
+ # No-op
+ ;;
+ *)
+ echo "Usage: $0 start|stop" >&2
+ exit 3
+ ;;
+esac