From owner-freebsd-threads@FreeBSD.ORG Fri Feb 4 04:08:46 2005 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9537E16A4CE for ; Fri, 4 Feb 2005 04:08:46 +0000 (GMT) Received: from pil.idi.ntnu.no (pil.idi.ntnu.no [129.241.107.93]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6878843D31 for ; Fri, 4 Feb 2005 04:08:45 +0000 (GMT) (envelope-from Tor.Egge@cvsup.no.freebsd.org) Received: from cvsup.no.freebsd.org (c2h5oh.idi.ntnu.no [129.241.103.69]) by pil.idi.ntnu.no (8.13.1/8.13.1) with ESMTP id j1448eVc016089 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 4 Feb 2005 05:08:40 +0100 (MET) Received: from localhost (localhost [127.0.0.1]) by cvsup.no.freebsd.org (8.13.1/8.13.1) with ESMTP id j1448eAP074368; Fri, 4 Feb 2005 04:08:40 GMT (envelope-from Tor.Egge@cvsup.no.freebsd.org) Date: Fri, 04 Feb 2005 04:08:39 +0000 (UTC) Message-Id: <20050204.040839.71152438.Tor.Egge@cvsup.no.freebsd.org> To: tomas@mysql.com From: Tor Egge In-Reply-To: <41FEB137.7040402@mysql.com> References: <41FEB137.7040402@mysql.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned-By: mimedefang.idi.ntnu.no, using FSAV X-SMTP-From: Sender=, Relay/Client=c2h5oh.idi.ntnu.no [129.241.103.69], EHLO=cvsup.no.freebsd.org X-Scanned-By: MIMEDefang 2.48 on 129.241.107.38 X-Scanned-By: mimedefang.idi.ntnu.no, using MIMEDefang 2.48 with local filter 16.42-idi X-Filter-Time: 2 seconds cc: freebsd-threads@freebsd.org Subject: Re: wrong exit code with linux threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2005 04:08:46 -0000 > > 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