[lxc-devel] [PATCH] lxc-shutdown: special handling for busybox init signals

Natanael Copa ncopa at alpinelinux.org
Fri Jan 4 09:15:21 UTC 2013


busybox uses different signals for poweroff and reboot. Check if init
is a symlink to busybox and use the busybox variants, USR2 and TERM.

Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
---
I have only tested this busybox so please test before pusing it.

Thanks!

 src/lxc/lxc-shutdown.in | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxc-shutdown.in b/src/lxc/lxc-shutdown.in
index edf735e..1a1f455 100644
--- a/src/lxc/lxc-shutdown.in
+++ b/src/lxc/lxc-shutdown.in
@@ -117,11 +117,21 @@ if [ "$pid" = "-1" ]; then
     exit 1
 fi
 
+signal_reboot=INT
+signal_poweroff=PWR
+init_exe=$(readlink -f /proc/$pid/exe)
+case ${init_exe} in
+    */busybox)
+        signal_reboot=TERM
+        signal_poweroff=USR2
+	;;
+esac
+
 if [ $reboot -eq 1 ]; then
-    kill -s INT $pid
+    kill -s $signal_reboot $pid
     exit 0
 else
-    kill -s PWR $pid
+    kill -s $signal_poweroff $pid
 fi
 
 if [ $dowait -eq 0 ]; then
-- 
1.8.0.3





More information about the lxc-devel mailing list