]> git.proxmox.com Git - mirror_lxc.git/commit
lxc-shutdown: Make all processes exit before timeout if shutdown works
authorChristian Seiler <christian@iwakd.de>
Sat, 30 Mar 2013 14:45:38 +0000 (15:45 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 1 Apr 2013 14:05:25 +0000 (10:05 -0400)
commit818fd9c7529fa22b16f214b4feedaa311497053f
tree1701225858176ea93eebe88aa50d5c38d69b2ec6
parentf3ca99fd5fe887adbb93ae56ccf629dfdd232070
lxc-shutdown: Make all processes exit before timeout if shutdown works

The following rationale is for using the -t option:

Currently, lxc-shutdown uses a subprocess for the timeout handling,
where a 'sleep $TIMEOUT' is executed, which will kill the main process
after the timeout has occurred, thus causing the main process to stop
the container hard with lxc-stop.

On the other hand, if the timeout is not reached, the main process
kills the subprocess. The trouble now is that if you kill a shell that
is running in the background, the kill will only take effect as soon as
the program currently running in the shell exits.

This in turn means that the subprocess will never terminate before
reaching the timeout. In an interactive shell, this does not matter,
since people will just not notice the process and lxc-shutdown returns
immediately. In a non-interactive enironment, however, there may be
circumstances that cause the calling program to wait until even that
subprocess is terminated, which means that shutdown will always take as
long as the timeout, even if the container shuts down quite a bit
earlier.

This change makes sure that also all subprocesses of the background
process are killed from the main process. This will immediately
terminate the background process, thus ensuring the desired behaviour.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc-shutdown.in