Date: Fri, 04 Feb 2005 04:08:39 +0000 (UTC) From: Tor Egge <Tor.Egge@cvsup.no.freebsd.org> To: tomas@mysql.com Cc: freebsd-threads@freebsd.org Subject: Re: wrong exit code with linux threads Message-ID: <20050204.040839.71152438.Tor.Egge@cvsup.no.freebsd.org> In-Reply-To: <41FEB137.7040402@mysql.com> References: <41FEB137.7040402@mysql.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> > Hi, > > the program below (tmp.c) gives strange output regarding the child exit > status when using linux threads on freebsd 4.7. > > With lib pthread- correct: > Exit value 123 > Exit value 123 > > With llthread - error: > Exit value 123 > Exit value 0 > > Any ideas? exit handling is known to be broken in the linuxthreads port, e.g. if one thread calls exit while other threads are still running then atexit handlers registered after the one registered by pthread_initialize() are called, and data structures might be removed while still being used by other threads. atexit handlers registered before the one registered by pthread_initialize() might not be called at all, since if other threads were killed while holding mutexes then the program would just hang. The exit code is not available for functions registered with atexit(), so terminating early with the exit code passed to exit is not easily done. Additionally, the command "gcc -o tmp tmp.c -L/usr/local/lib -llthread" is wrong unless you've compiled the linuxthread port with support for emulating the ABI for native threads (LINUXTHREADS_WRAP_API=yes). You need to specify where to find the corresponding header files, i.e. "-I/usr/local/include/pthread/linuxthreads" has to be added to the command. If you compile the linuxthreads port with LINUXTHREADS_DETECT_UNSAFE_EXIT=yes then your sample program seems to exit with the correct exit code. But that has other side effects, e.g. when it was implicit in version 2.2.3_9 of the linuxthreads port, people reported that /usr/local/bin/mysql_install_db checked the exit code of mysqld and aborted. - Tor Egge
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050204.040839.71152438.Tor.Egge>