[lxc-devel] "Shutdown" LXC container

Tobias Gruetzmacher tobias-lists at 23.gs
Mon May 16 20:47:04 UTC 2011


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

-- 
My blog: http://blog.23.gs/
GPG-Key 0xE2BEA341 - signed/encrypted mail preferred
http://www.fli4l.de/ - ISDN- & DSL-Router on one disk!
Registered FLI4L-User #00000003
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20110516/9e3e7e9d/attachment.pgp>


More information about the lxc-devel mailing list