[systemd-devel] [PATCH] nspawn: document how to enter the namespace

Lennart Poettering lennart at poettering.net
Tue Jan 15 19:41:41 PST 2013


On Sat, 12.01.13 16:55, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> systemd-nspawn will now print the PID of the child.
> ---
> To be applied after Linux 3.8 is released and after util-linux
> decided on the interface to setns(). Current unshare invocation
> is ugly and unwieldy. A seperate command (enter), was proposed...
> So I'm holding this in my queue for now.

Ah, interesting stuff, I wasn't aware the unshare utility could do that
already.

> +                        close(pipefd[1]);
> +                        fd_wait_for_event(pipefd[0], POLLHUP, -1);
> +                        close(pipefd[0]);

close_nointr_fail() is usually better than just ignoring the ret val of close().

> +                log_info("Init process in the container running as PID %d", pid);
> +                close(pipefd[0]);
> +                close(pipefd[1]);

There's close_pipe() btw, which is sometimes handy to turn these 2 lines
into 1. Yay!

Cool stuff! Love it. I was always scratching my head how to implement
something like this best, but was mostly thinking how to tell nspawn to
fork off a shell for us, since I didn't think setns() would work so
nicely for us...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list