[lxc-devel] [PATCH 0/5] Signal stuff v2 and some documentation

Ferenc Wagner wferi at niif.hu
Thu Jun 10 21:47:39 UTC 2010


Daniel Lezcano <daniel.lezcano at free.fr> writes:

> On 06/09/2010 07:56 PM, Ferenc Wagner wrote:
>
>> here are basically the same patches, with some obvious errors corrected
>> and some unrelated documentation added.  It actually survived some
>> targeted testing in the past days and seems to behave as expected, ie.
>>
>> # lxc-start -n s -- sh -c "trap 'echo TERM' TERM; sleep 10"
>>
>> can be interrupted by Ctrl-C from the terminal (the sleep process does
>> not ignore the SIGINT sent to the foreground process group by the OS),
>> while a
>>
>> # pkill lxc-start
>>
>> does not terminate the sleep as the SIGTERM gets forwarded to the shell
>> only, which reports it after the sleep expires.  This forwarding
>> mechanism makes it possible to plug lxc into our batch queueing system.
>
> The patchset looks good to me, but while playing with it and I noticed
> it breaks the console when lxc.console=$(tty). The lxc-start process
> behave strangely (I suppose we receive a SIGTTOU or something
> similar).
>
> I will look later what is going on.

I don't know what lxc.console does, but the NOTES section of setpgid(2)
may be relevant here:

       Only the foreground process group may read(2) from the terminal;
       if a background process group tries to read(2) from the terminal,
       then the group is sent a SIGTSTP signal, which suspends it.

After calling tcsetpgrp(), lxc-start isn't in the foreground process
group anymore, so it's sent a SIGTSTP signal if it reads from its
controlling terminal, which it forwards to its child, which probably
leads to confusion.  If you provide me with an example (and some
description of lxc.console), I can give it some testing and concretize
this pure guesswork.

Also, SIGTTOU is mentioned in tcsetpgrp(3):

       If tcsetpgrp() is called by a member of a background process
       group in its session, and the calling process is not blocking or
       ignoring SIGTTOU, a SIGTTOU signal is sent to all members of this
       background process group.

I admittedly didn't test running lxc-start in the background, but it
blocks SIGTTOU, so it should be unaffected...
-- 
Cheers,
Feri.




More information about the lxc-devel mailing list