[lxc-devel] liblxc problems

Stéphane Graber stgraber at ubuntu.com
Thu Nov 6 15:15:08 UTC 2014


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).

> And the second problem with start:
> My process (1) uses a lot of resources (RAM), process (2) is forked
> from (1). It is not the problem when process (1) is alive (because
> of copy-on-write) but when process (1) die then process (2) uses
> unnecessarily more memory than it should. I propose to use fork+exec
> here.

A simple fork+exec is not an option because the intermediate process is
there for a reason. It's the monitoring process for the container, it
listens on the LXC command socket and is responsible for things like
returning information for lxc-info, some bits of lxc-attach and proper
tear down of the container on shutdown or reboot.

> 
> Thanks,
> Piotrek
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20141106/fb333daf/attachment.sig>


More information about the lxc-devel mailing list