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

Stéphane Graber stgraber at ubuntu.com
Fri Jan 4 15:14:19 UTC 2013


On 01/04/2013 04:15 AM, Natanael Copa wrote:
> 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>

We quickly talked about this with Serge and we seem to agree that we
shouldn't special-case init systems like this.

Instead what should be done is make lxc-shutdown a part of lxc-stop
(in C) and have it call the shutdown feature of the API, reducing the
whole thing to a single code path.

Then we should introduce two new config options along the lines of:
lxc.signals.shutdown
lxc.signals.reboot

That would default to SIGINIT and SIGPWR respectively, so distributions
using init systems that don't use those signals can have their template
write the additional config entries.

> ---
> 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
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130104/1408acf4/attachment.pgp>


More information about the lxc-devel mailing list