* nsenter and SIGSTOP
[not found] <20130417155727.GE19116@tango.0pointer.de>
@ 2013-04-20 18:23 ` Zbigniew Jędrzejewski-Szmek
2013-04-20 22:27 ` [systemd-devel] " Eric W. Biederman
0 siblings, 1 reply; 8+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2013-04-20 18:23 UTC (permalink / raw)
To: util-linux, ebiederm; +Cc: systemd-devel
Hi,
I've hit a bit of a problem with nsenter and systemd-nspawn.
When nsenter is used to enter the PID namespace created with
systemd-nspawn, and the container's init attempts a shutdown,
it hangs because nsenter is suspended.
The sequence of events leading to the hang is:
1. nsenter launches a shell inside the container with
PPID=0 as seen inside the container,
2. systemd with PID=1 goes through the shutdown sequence,
issuing the equivalent(*) of
kill(-1, SIGSTOP)
kill(-1, SIGTERM)
kill(_1, SIGCONT)
reboot(RB_HALT_SYSTEM)
Now, nsenter has a stanza in continue_as_child where it stops itself
when the child gets stopped. Unfortunately, this means that nsenter
gets stopped in response to kill(-1, SIGSTOP) which hits the child.
Then the child dies on kill(-1, SIGTERM), is resumed with kill(-1,
SIGCONT) and exits (it prints "exit", so it's easy to see that it
terminated properly. Then the shell becomes a zombie, since nsenter it
it's parent and it's sleeping. Meanwhile, init executes reboot, and
hangs in there, since the container waits for the PID namespace to
become empty (I'm guessing here, but that seems logical). When then
I type 'fg' to continue nsenter, the child gets collected and the
container successfully exits.
This is with kernel 3.9-rc6 from Fedora.
Thanks,
Zbyszek
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [systemd-devel] nsenter and SIGSTOP
2013-04-20 18:23 ` nsenter and SIGSTOP Zbigniew Jędrzejewski-Szmek
@ 2013-04-20 22:27 ` Eric W. Biederman
2013-04-21 13:21 ` Lennart Poettering
2013-04-21 14:45 ` Zbigniew Jędrzejewski-Szmek
0 siblings, 2 replies; 8+ messages in thread
From: Eric W. Biederman @ 2013-04-20 22:27 UTC (permalink / raw)
To: Zbigniew Jędrzejewski-Szmek; +Cc: util-linux, systemd-devel
WmJpZ25p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vdGhlcndpc2Ugbm90IGxlYXZpbmcKcHJvY2Vzc2VzIHdpdGggcGFyZW50cyBvdXRz
aWRlIHRoZSBwaWQgbmFtZXNwYWNlIGFyb3VuZC4KCk9mIGNvdXJzZSB0aGF0IHNlZGluZyBTSUdT
VE9QIGJlZm9yZSBzZW5kaW5nIFNJR1RFUk0gc2VlbXMgbWlnaHR5IGZpc2h5CmFzIHdlbGwuCgpF
cmljCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCnN5c3Rl
bWQtZGV2ZWwgbWFpbGluZyBsaXN0CnN5c3RlbWQtZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3Jn
Cmh0dHA6Ly9saXN0cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9zeXN0ZW1kLWRl
dmVsCg==
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [systemd-devel] nsenter and SIGSTOP
2013-04-20 22:27 ` [systemd-devel] " Eric W. Biederman
@ 2013-04-21 13:21 ` Lennart Poettering
2013-04-21 14:45 ` Zbigniew Jędrzejewski-Szmek
1 sibling, 0 replies; 8+ messages in thread
From: Lennart Poettering @ 2013-04-21 13:21 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Zbigniew Jędrzejewski-Szmek, util-linux, systemd-devel
On Sat, 20.04.13 15:27, Eric W. Biederman (ebiederm@xmission.com) wrote:
> Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
>
> > Hi,
> > I've hit a bit of a problem with nsenter and systemd-nspawn.
> > When nsenter is used to enter the PID namespace created with
> > systemd-nspawn, and the container's init attempts a shutdown,
> > it hangs because nsenter is suspended.
> >
> > The sequence of events leading to the hang is:
> >
> > 1. nsenter launches a shell inside the container with
> > PPID=0 as seen inside the container,
> > 2. systemd with PID=1 goes through the shutdown sequence,
> > issuing the equivalent(*) of
> >
> > kill(-1, SIGSTOP)
>
> This baffles me. I am not certain why someone whould send SIGSTOP
> when the want processes to exit. I'm not even saying it's wrong just
> saying that is odd.
This is how the killing spree generally worked on sysvinit systems too:
if we kill all remaining processes, then this might kill processes that
are children of others. Now, in general it is preferable getting the
SIGTERM/SIGKILL delivered to all these processes before possible SIGCHLD
signals for their dying children. Why? Simply to avoid log spew with
messages such as "Worker child process xyz died abnormally" generated by
the various system daemons.
By pausing all processes before delivering the SIGTERM/SIGKILL we can
ensure that if they are unpaused again the SIGTERM/SIGKILL is guaranteed
to be queued for each process and since on Linux lower-numbered signals
are guaranteed to be dispatched before higher-numbered signals (and
SIGKILL/SIGTERM is lower than SIGCHLD) we get the desired behaviour that
daemons exit quickly on SIGTERM/SIGKILL before handling the SIGCHLD.
Here's the code in sysvinit:
http://svn.savannah.nongnu.org/viewvc/sysvinit/trunk/src/killall5.c?revision=117&root=sysvinit&view=markup
Look for "kill(-1, SIGSTOP)".
Here's the code in systemd:
http://cgit.freedesktop.org/systemd/systemd/tree/src/core/killall.c#n185
Lennart
--
Lennart Poettering - Red Hat, Inc.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: nsenter and SIGSTOP
2013-04-20 22:27 ` [systemd-devel] " Eric W. Biederman
2013-04-21 13:21 ` Lennart Poettering
@ 2013-04-21 14:45 ` Zbigniew Jędrzejewski-Szmek
2013-04-21 14:50 ` [not-for-applying PATCH] nsenter: do not self-suspend if child is suspended Zbigniew Jędrzejewski-Szmek
2013-04-21 16:18 ` nsenter and SIGSTOP Eric W. Biederman
1 sibling, 2 replies; 8+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2013-04-21 14:45 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: util-linux, systemd-devel
On Sat, Apr 20, 2013 at 03:27:46PM -0700, Eric W. Biederman wrote:
> Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
>
> > Hi,
> > I've hit a bit of a problem with nsenter and systemd-nspawn.
> > When nsenter is used to enter the PID namespace created with
> > systemd-nspawn, and the container's init attempts a shutdown,
> > it hangs because nsenter is suspended.
> >
> > The sequence of events leading to the hang is:
> >
> > 1. nsenter launches a shell inside the container with
> > PPID=0 as seen inside the container,
> > 2. systemd with PID=1 goes through the shutdown sequence,
> > issuing the equivalent(*) of
> >
> > kill(-1, SIGSTOP)
>
> This baffles me. I am not certain why someone whould send SIGSTOP
> when the want processes to exit. I'm not even saying it's wrong just
> saying that is odd.
Like Lennart wrote, it's for atomicity of the subsequent killing.
> > kill(-1, SIGTERM)
> > kill(_1, SIGCONT)
> > reboot(RB_HALT_SYSTEM)
> >
> > Now, nsenter has a stanza in continue_as_child where it stops itself
> > when the child gets stopped. Unfortunately, this means that nsenter
> > gets stopped in response to kill(-1, SIGSTOP) which hits the child.
> > Then the child dies on kill(-1, SIGTERM), is resumed with kill(-1,
> > SIGCONT) and exits (it prints "exit", so it's easy to see that it
> > terminated properly. Then the shell becomes a zombie, since nsenter it
> > it's parent and it's sleeping. Meanwhile, init executes reboot, and
> > hangs in there, since the container waits for the PID namespace to
> > become empty (I'm guessing here, but that seems logical).
>
> I expect the hang is in the pid namespace init exiting.
> in kernel/pid_namespace.x:zap_pid_ns_processes() has the baviour of
> blocking until all children of init have been reaped that you describe.
>
> > When then
> > I type 'fg' to continue nsenter, the child gets collected and the
> > container successfully exits.
> >
> > This is with kernel 3.9-rc6 from Fedora.
>
> For nsenter and the pid namespace they are working as designed. But
> given this outcode it would be nice if we could get a SIGCONT when the
> child wakes up again.
I don't know how the kernel could know what is wanted. nsenter
signalled itself, and the kernel had nothing to with that.
> The current behavior supports being able to type suspend in your shell
> in the namespace and able to work outside the namespace.
>
> I can't think of a way off the top of my head to wake nsenter up when
> it's child is woken up underneath it, but it sounds like that would be
> nice to do.
>
> For the short term I would recommend not typing "reboot & exit" instead
> of "reboot" from a shell started with nsenter, and otherwise not leaving
> processes with parents outside the pid namespace around.
'reboot & exit' would suffer from the same problem, just with a race.
Even 'exec reboot' would, since the container shuts down quite quickly,
and the 'reboot' process could get SIGSTOPped before exiting.
> Of course that seding SIGSTOP before sending SIGTERM seems mighty fishy
> as well.
It's not entirely fishy, but I think that the implementation in
systemd might require some revisiting. systemd currently stops (and
resumes) all processes, even the ones which are exempt from killing.
But it's independent of this problem, since systemd does not exempt
the injected shell from killing.
Whether nsenter should be "fixed" depends on the main purpose of
nsenter. If it's supposed to be used to launch arbitrary services,
then it might be changed, if comfortable use of a shell is more
important. I'll post a patch to remove the self-suspend, but I'm not
really sure if it should be applied. Probably not.
For systemd-nspawn, we'll grow our own facility to enter the
container, since we want to set the environment and find the container
by name and in general integrate with systemd-nspawn. So there's
little reason to modify nsenter for this purpose.
Zbyszek
^ permalink raw reply [flat|nested] 8+ messages in thread
* [not-for-applying PATCH] nsenter: do not self-suspend if child is suspended
2013-04-21 14:45 ` Zbigniew Jędrzejewski-Szmek
@ 2013-04-21 14:50 ` Zbigniew Jędrzejewski-Szmek
2013-04-21 16:18 ` nsenter and SIGSTOP Eric W. Biederman
1 sibling, 0 replies; 8+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2013-04-21 14:50 UTC (permalink / raw)
To: Eric W. Biederman, util-linux
Cc: systemd-devel, Zbigniew Jędrzejewski-Szmek
nsenter would kill(self, SIGSTOP) when the child was stopped,
making it possible to use 'suspend -f' in the child shell to
suspend both the shell and the parent nsenter process. Unfortunately
this interferes with other uses of SIGSTOP, since nsenter process
is not visible in the child PID namespace and can be only resumed
from outside.
---
sys-utils/nsenter.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
index 106349c..5cef4bf 100644
--- a/sys-utils/nsenter.c
+++ b/sys-utils/nsenter.c
@@ -129,7 +129,6 @@ static void continue_as_child(void)
{
pid_t child = fork();
int status;
- pid_t ret;
if (child < 0)
err(EXIT_FAILURE, _("fork failed"));
@@ -138,16 +137,8 @@ static void continue_as_child(void)
if (child == 0)
return;
- for (;;) {
- ret = waitpid(child, &status, WUNTRACED);
- if ((ret == child) && (WIFSTOPPED(status))) {
- /* The child suspended so suspend us as well */
- kill(getpid(), SIGSTOP);
- kill(child, SIGCONT);
- } else {
- break;
- }
- }
+ waitpid(child, &status, 0);
+
/* Return the child's exit code if possible */
if (WIFEXITED(status)) {
exit(WEXITSTATUS(status));
--
1.8.2.562.g931e949
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: nsenter and SIGSTOP
2013-04-21 14:45 ` Zbigniew Jędrzejewski-Szmek
2013-04-21 14:50 ` [not-for-applying PATCH] nsenter: do not self-suspend if child is suspended Zbigniew Jędrzejewski-Szmek
@ 2013-04-21 16:18 ` Eric W. Biederman
2013-04-21 19:33 ` [systemd-devel] " Zbigniew Jędrzejewski-Szmek
1 sibling, 1 reply; 8+ messages in thread
From: Eric W. Biederman @ 2013-04-21 16:18 UTC (permalink / raw)
To: Zbigniew Jędrzejewski-Szmek; +Cc: util-linux, systemd-devel
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
> On Sat, Apr 20, 2013 at 03:27:46PM -0700, Eric W. Biederman wrote:
>> Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
>>
>> > Hi,
>> > I've hit a bit of a problem with nsenter and systemd-nspawn.
>> > When nsenter is used to enter the PID namespace created with
>> > systemd-nspawn, and the container's init attempts a shutdown,
>> > it hangs because nsenter is suspended.
>> >
>> > The sequence of events leading to the hang is:
>> >
>> > 1. nsenter launches a shell inside the container with
>> > PPID=0 as seen inside the container,
>> > 2. systemd with PID=1 goes through the shutdown sequence,
>> > issuing the equivalent(*) of
>> >
>> > kill(-1, SIGSTOP)
>>
>> This baffles me. I am not certain why someone whould send SIGSTOP
>> when the want processes to exit. I'm not even saying it's wrong just
>> saying that is odd.
> Like Lennart wrote, it's for atomicity of the subsequent killing.
When you don't do kill(-1, SIGTERM) that makes sense.
>
>> > kill(-1, SIGTERM)
>> > kill(_1, SIGCONT)
>> > reboot(RB_HALT_SYSTEM)
>> >
>> > Now, nsenter has a stanza in continue_as_child where it stops itself
>> > when the child gets stopped. Unfortunately, this means that nsenter
>> > gets stopped in response to kill(-1, SIGSTOP) which hits the child.
>> > Then the child dies on kill(-1, SIGTERM), is resumed with kill(-1,
>> > SIGCONT) and exits (it prints "exit", so it's easy to see that it
>> > terminated properly. Then the shell becomes a zombie, since nsenter it
>> > it's parent and it's sleeping. Meanwhile, init executes reboot, and
>> > hangs in there, since the container waits for the PID namespace to
>> > become empty (I'm guessing here, but that seems logical).
>>
>> I expect the hang is in the pid namespace init exiting.
>> in kernel/pid_namespace.x:zap_pid_ns_processes() has the baviour of
>> blocking until all children of init have been reaped that you describe.
>>
>> > When then
>> > I type 'fg' to continue nsenter, the child gets collected and the
>> > container successfully exits.
>> >
>> > This is with kernel 3.9-rc6 from Fedora.
>>
>> For nsenter and the pid namespace they are working as designed. But
>> given this outcode it would be nice if we could get a SIGCONT when the
>> child wakes up again.
> I don't know how the kernel could know what is wanted. nsenter
> signalled itself, and the kernel had nothing to with that.
No. However it is possible to get a notification when the child wakes
up, and even more when the child is killed (SIGCHLD).
The question is can those facilities be used without making the code
incomprehensible both to readers and to users of nsenter.
>> The current behavior supports being able to type suspend in your shell
>> in the namespace and able to work outside the namespace.
>>
>> I can't think of a way off the top of my head to wake nsenter up when
>> it's child is woken up underneath it, but it sounds like that would be
>> nice to do.
>>
>> For the short term I would recommend not typing "reboot & exit" instead
>> of "reboot" from a shell started with nsenter, and otherwise not leaving
>> processes with parents outside the pid namespace around.
> 'reboot & exit' would suffer from the same problem, just with a race.
> Even 'exec reboot' would, since the container shuts down quite quickly,
> and the 'reboot' process could get SIGSTOPped before exiting.
Well when this happens with ssh "reboot & exit" has a pretty good track
record of working. 'shutdown -r "now + 1 minute" &' might even be
better.
When you are interactive I don't imaginge going "doh!" and typing fg
is not going to be particularly hard either.
>> Of course that seding SIGSTOP before sending SIGTERM seems mighty fishy
>> as well.
> It's not entirely fishy, but I think that the implementation in
> systemd might require some revisiting. systemd currently stops (and
> resumes) all processes, even the ones which are exempt from killing.
> But it's independent of this problem, since systemd does not exempt
> the injected shell from killing.
>
> Whether nsenter should be "fixed" depends on the main purpose of
> nsenter. If it's supposed to be used to launch arbitrary services,
> then it might be changed, if comfortable use of a shell is more
> important. I'll post a patch to remove the self-suspend, but I'm not
> really sure if it should be applied. Probably not.
Launching completely arbitrary services really isn't the main purposes.
Any time use setns to launch processes in a pid namespace the process
tree becomes multi-rooted which is not a good place to be. So at the
very least everything you "launch" needs to be daemonized.
nsenter should remove the need to run sshd do in a container.
As I see it the main purpose of nsenter is to be a simple, easily
understood tool that let's you get inside of a container and do things.
It should be comfortable and useful to use as much as possible.
Which means it should be possible to use the "suspend" command in bash
possible. There are folks for whom their workflow breaks when that
command does not work.
So I guess I am saying I would bias nsenter towards the interactive users
rather than scripted automation.
> For systemd-nspawn, we'll grow our own facility to enter the
> container, since we want to set the environment and find the container
> by name and in general integrate with systemd-nspawn. So there's
> little reason to modify nsenter for this purpose.
Sounds reaasonable to me. Just make certain multiple roots in the pid
namespace doing mess you up.
Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [systemd-devel] nsenter and SIGSTOP
2013-04-21 16:18 ` nsenter and SIGSTOP Eric W. Biederman
@ 2013-04-21 19:33 ` Zbigniew Jędrzejewski-Szmek
2013-04-21 22:07 ` Eric W. Biederman
0 siblings, 1 reply; 8+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2013-04-21 19:33 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: util-linux, systemd-devel
T24gU3VuLCBBcHIgMjEsIDIwMTMgYXQgMDk6MTg6MzRBTSAtMDcwMCwgRXJpYyBXLiBCaWVkZXJt
YW4gd3JvdGU6Cj4gWmJpZ25pZXcgSsSZZHJ6ZWpld3NraS1Tem1layA8emJ5c3pla0Bpbi53YXcu
cGw+IHdyaXRlczoKPiAKPiA+IE9uIFNhdCwgQXByIDIwLCAyMDEzIGF0IDAzOjI3OjQ2UE0gLTA3
MDAsIEVyaWMgVy4gQmllZGVybWFuIHdyb3RlOg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zcGFjZSBkb2luZyBtZXNzIHlvdSB1cC4KWWVhaCwg
bXVsdGlwbGUgcm9vdHMgd2l0aCB1bmtpbGxhYmxlIHpvbWJpZSBwcm9jZXNzZXMgc3VyZWx5IGFy
ZSBlbm91Z2gKdG8gbWFrZSBwZW9wbGUgY29uZnVzZWQuIEknbSBzdGlsbCB0cnlpbmcgdG8gd3Jh
cCBteSBoZWFkIGFyb3VuZCBQSUQKYW5kIG1vdW50IG5hbWVzcGFjZXMsIGFuZCBJIGtub3cgdGhh
dCB1c2VyIG5hbWVzcGFjZXMgYWRkIGFub3RoZXIgbGV2ZWwKb2YgZnVuIDopLgoKWmJ5c3plawpf
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXwpzeXN0ZW1kLWRl
dmVsIG1haWxpbmcgbGlzdApzeXN0ZW1kLWRldmVsQGxpc3RzLmZyZWVkZXNrdG9wLm9yZwpodHRw
Oi8vbGlzdHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vc3lzdGVtZC1kZXZlbAo=
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: nsenter and SIGSTOP
2013-04-21 19:33 ` [systemd-devel] " Zbigniew Jędrzejewski-Szmek
@ 2013-04-21 22:07 ` Eric W. Biederman
0 siblings, 0 replies; 8+ messages in thread
From: Eric W. Biederman @ 2013-04-21 22:07 UTC (permalink / raw)
To: Zbigniew Jędrzejewski-Szmek; +Cc: util-linux, systemd-devel
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
> On Sun, Apr 21, 2013 at 09:18:34AM -0700, Eric W. Biederman wrote:
>> Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
>>
>> > On Sat, Apr 20, 2013 at 03:27:46PM -0700, Eric W. Biederman wrote:
>> >> Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
>> >>
>> >> > Hi,
>> >> > I've hit a bit of a problem with nsenter and systemd-nspawn.
>> >> > When nsenter is used to enter the PID namespace created with
>> >> > systemd-nspawn, and the container's init attempts a shutdown,
>> >> > it hangs because nsenter is suspended.
>> >> >
>> >> > The sequence of events leading to the hang is:
>> >> >
>> >> > 1. nsenter launches a shell inside the container with
>> >> > PPID=0 as seen inside the container,
>> >> > 2. systemd with PID=1 goes through the shutdown sequence,
>> >> > issuing the equivalent(*) of
>> >> >
>> >> > kill(-1, SIGSTOP)
>> >>
>> >> This baffles me. I am not certain why someone whould send SIGSTOP
>> >> when the want processes to exit. I'm not even saying it's wrong just
>> >> saying that is odd.
>> > Like Lennart wrote, it's for atomicity of the subsequent killing.
>>
>> When you don't do kill(-1, SIGTERM) that makes sense.
> Because not all processes are killed: during normal shutdown processes
> with argv[0] beginning with @ are spared
> (http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons).
I wasn't arguing. But since you bring up root storage daemons and
initial ram disks, I don't believe any of those actually apply to a
container.
My point was only that using SIGSTOP makes sense when it becomes clear
that kill(-1, SIGTERM) is not happening.
>> No. However it is possible to get a notification when the child wakes
>> up, and even more when the child is killed (SIGCHLD).
> Right, but that doesn't help at all, since nsenter is sleeping. It'll
> get the notification, when it wakes up, but there's nothing to wake it
> up.
I believe you could make it all work with a poll based on a periodic
wake up. If you don't send yourself SIGSTOP I don't believe the outer
shell will recognize what has happened, but you should be able to wake
yourself up with a timer and see verify you child is still stopped.
>> Well when this happens with ssh "reboot & exit" has a pretty good track
>> record of working. 'shutdown -r "now + 1 minute" &' might even be
>> better.
>>
>> When you are interactive I don't imaginge going "doh!" and typing fg
>> is not going to be particularly hard either.
> We're trying to get things to work without kludges like sleeping or
> manual prodding. For debugging that's fine, but people use systemd-nspawn
> containers for services, and expect them to "just work".
Like I said below nsenter is about interactive/debugging case. More
sysadmin debugging than application debugging but I guess that makes
it debugging.
Essentially that was the point of implementing setns for the pid
namespace. So you exceptional cases could be handled without having to
got to the expense of having to depend on a functioning login daemon in
the container.
>> So I guess I am saying I would bias nsenter towards the interactive users
>> rather than scripted automation.
> Agreed.
>
>> > For systemd-nspawn, we'll grow our own facility to enter the
>> > container, since we want to set the environment and find the container
>> > by name and in general integrate with systemd-nspawn. So there's
>> > little reason to modify nsenter for this purpose.
>>
>> Sounds reaasonable to me. Just make certain multiple roots in the pid
>> namespace doing mess you up.
> Yeah, multiple roots with unkillable zombie processes surely are enough
> to make people confused. I'm still trying to wrap my head around PID
> and mount namespaces, and I know that user namespaces add another level
> of fun :).
Well this isn't a case of unkillable zombies. This is a case of
processes not being reaped. And a weird process that doesn't fully die
until all of it's children are dead (similar to the leader of a thread
group). Now honestly I would not be adverse in theory to handling this
weird corrner case better in zap_pid_ns_processes. Right now
zap_pid_ns_processes is the best so far.
For launching new services in a container simply sending a message to
the init process is probably what you want. I think those messages
already traverse unix domain sockets so it insn't too shabby.
Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-04-21 22:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20130417155727.GE19116@tango.0pointer.de>
2013-04-20 18:23 ` nsenter and SIGSTOP Zbigniew Jędrzejewski-Szmek
2013-04-20 22:27 ` [systemd-devel] " Eric W. Biederman
2013-04-21 13:21 ` Lennart Poettering
2013-04-21 14:45 ` Zbigniew Jędrzejewski-Szmek
2013-04-21 14:50 ` [not-for-applying PATCH] nsenter: do not self-suspend if child is suspended Zbigniew Jędrzejewski-Szmek
2013-04-21 16:18 ` nsenter and SIGSTOP Eric W. Biederman
2013-04-21 19:33 ` [systemd-devel] " Zbigniew Jędrzejewski-Szmek
2013-04-21 22:07 ` Eric W. Biederman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox