[lxc-devel] [PATCH] Use pthread_atfork() to unlock mutexes after fork()

Serge Hallyn serge.hallyn at ubuntu.com
Thu Jan 2 14:59:10 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> On Wed, Jan 01, 2014 at 11:37:32PM -0600, Serge Hallyn wrote:
> > Quoting Stéphane Graber (stgraber at ubuntu.com):
> > > This patch caused a build failure on Android:
> > > 
> > > arm-linux-androideabi-gcc --sysroot=/tmp/android-build-scripts/android-ndk-r9b/platforms/android-9/arch-arm/ -DHAVE_CONFIG_H -I. -I../../src    -fPIC -DPIC -I../../src -DLXCROOTFSMOUNT=\"/data/lxc/lxc/lib/lxc/rootfs\" -DLXCPATH=\"/data/lxc/lxc/var/lib/lxc\" -DLXC_GLOBAL_CONF=\"/data/lxc/lxc/etc/lxc/lxc.conf\" -DLXCINITDIR=\"/data/lxc/lxc/libexec\" -DLXCTEMPLATEDIR=\"/data/lxc/lxc/share/lxc/templates\" -DLOGPATH=\"/data/lxc/lxc/var/log/lxc\" -DLXC_DEFAULT_CONFIG=\"/data/lxc/lxc/etc/lxc/default.conf\" -DLXClxclock.c: In function 'process_lock_setup_atfork':
> > > lxclock.c:332:2: error: implicit declaration of function 'pthread_atfork' [-Werror=implicit-function-declaration]
> > >   pthread_atfork(process_lock, process_unlock, process_unlock);
> > 
> > Hm,  according to
> > http://stackoverflow.com/questions/12370970/undefined-reference-to-pthread-atfork-while-i-was-trying-to-port-libpcsclite-t
> > perhaps all we need is to declare the fn before its use.  Do you
> > have a local bionic compiler handy to test that on?
> 
> Not having much luck with that... this just turned it into:
> 
> liblxc.so: error: undefined reference to 'pthread_atfork'
> 
> pthread on bionic is part of the C library so no extra linker flags
> should be needed to make this work...

Hm.  So we can either (a) keep looking for a way to make it work in
bionic, (b) give in and switch all uses of fork() to lxc_fork() to
do our own atfork hook, or (c) detect at configure.ac whether we have
pthread_atfork(), and if not then just don't do it.

-serge


More information about the lxc-devel mailing list