[lxc-devel] "Shutdown" LXC container

Christoph Mitasch cmitasch at thomas-krenn.com
Mon May 23 14:10:26 UTC 2011


Hi Tobias,

thanks for the detailed research on that.

You are actually right and I got it working using sysvinit on Debian
Squeeze. I just had to add the following line to /etc/inittab:
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now

The lxc-debian template script creates a minimal /etc/inittab without
the "ca" line.

Christoph

On 05/16/2011 10:47 PM, Tobias Gruetzmacher wrote:
> Hi,
> 
> On Mon, May 16, 2011 at 10:01:31AM +0200, Christoph Mitasch wrote:
>> the idea is actually good, but my experience is that modern Linux
>> distros are unable to shutdown with "kill -s INT/PWR".
> 
> Well. I consider the default setup of your "modern" Linux distros
> broken. So pressing Ctrl+Alt+Del on those does nothing? At all?
> 
>> I tested on Debian Squeeze and Ubuntu Natty and it didn't work. What
>> distro are you using?
> 
> Debian on Debian. Works out of the box. And just for the fun of it:
> 
> For reference: On a "normal" system, the Linux kernel sends SIGINT to
> PID 1 when a "keyboard interrupt" (Ctrl+Alt+Del) is received. Search for
> ctrl_alt_del and kill_cad_pid in the kernel for details.
> 
> What actually happens after PID 1 receives the signal is a policy
> decision. Let's see how different processes running as PID 1 handle
> this (I'm using Debian packages as reference, see those for versions):
> 
> * sysvinit (2.88dsf-13.6)
> 
> As seen in src/init.c, lines 2429-2441, this just runs the ctrlaltdel
> entry from /etc/inittab, which can be configured to shut down the
> container.
> 
> * upstart (0.6.6-2):
> 
> If I see this correctly, in init/main.c, line 453, there is a signal
> handle for SIGINT. There even is a default job file to handle this event
> at conf/control-alt-delete.conf.
> 
> * systemd (25-2):
> 
> The code to handle this is in src/manager.c, lines 2120-2132. This
> triggers ctrl-alt-del.target, which seems to be an alias for either
> halt, reboot or poweroff, maybe based on a symlink?
> 
> * runit (2.1.1-6.2):
> 
> Handler is in src/runit.c lines 38-41 and seems to trigger a state
> transition in lines 220-241. Looks sane.
> 
> 
> 
> So it SEEMS that any "modern" init system should handle SIGINT just
> fine. If they don't, now would be a good time to find out why...
> 
> Have a nice day, Tobias




More information about the lxc-devel mailing list