[lxc-devel] liblxc problems

Serge Hallyn serge.hallyn at ubuntu.com
Fri Nov 7 09:50:49 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> On Thu, Nov 06, 2014 at 01:10:45PM +0100, Piotr Bartosiewicz wrote:
> > Hi,
> > 
> > I am trying to use liblxc in my project. Previously I was using
> > libvirt and everything was ok, but after switching to lxc I found
> > one issue.
> > After invoking lxc->start ps shows sth like this:
> > 
> > _ (1) my-process
> > _   \_ (2) my-process (forked)
> > _      \_ (3) container-init
> > 
> > The problem is with process (2). It appears that this process holds
> > all the file descriptor copied from process (1). In my case it's a
> > real problem because one of this file descriptors is a dbus socket
> > and after process (1) death, process (2) still holds process (1)
> > dbus name.
> > 
> > After looking into sources I've found a missing piece of code like
> > (as opposed to the libvirt):
> > 
> > maxfd = sysconf(_SC_OPEN_MAX);
> > for (fd = 0; fd < maxfd; fd++)
> >     close(fd);
> 
> Indeed sounds like a bug, those fds should be closed immediately after
> fork unless we ask LXC to keep them open (I believe there's a flag for
> that).

The flag isn't to keep them open, it's to specify whether to close the
fds, or exit with failure if any are open.  But we do that for the thread
that becomes the container init (i.e. (3) above).

If you don't mind, please open a github issue and feel free to assign it
to me.  (Or send a patch of course :)

thanks,
-serge


More information about the lxc-devel mailing list