From owner-freebsd-questions@FreeBSD.ORG Sat Oct 31 15:17:09 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D84C1065670 for ; Sat, 31 Oct 2009 15:17:09 +0000 (UTC) (envelope-from psteele@maxiscale.com) Received: from server505.appriver.com (server505b.appriver.com [98.129.35.5]) by mx1.freebsd.org (Postfix) with ESMTP id 45BF88FC12 for ; Sat, 31 Oct 2009 15:17:08 +0000 (UTC) X-Policy: GLOBAL - maxiscale.com X-Primary: psteele@maxiscale.com X-Note: This Email was scanned by AppRiver SecureTide X-ALLOW: psteele@maxiscale.com ALLOWED X-Virus-Scan: V- X-Note: Spam Tests Failed: X-Country-Path: UNITED STATES->UNITED STATES->UNITED STATES X-Note-Sending-IP: 98.129.23.14 X-Note-Reverse-DNS: ht01.exg5.exghost.com X-Note-WHTLIST: psteele@maxiscale.com X-Note: User Rule Hits: X-Note: Global Rule Hits: 112 113 114 115 119 120 131 217 X-Note: Mail Class: ALLOWEDSENDER X-Note: Headers Injected Received: from [98.129.23.14] (HELO ht01.exg5.exghost.com) by server505.appriver.com (CommuniGate Pro SMTP 5.2.14) with ESMTPS id 12496783 for freebsd-questions@freebsd.org; Sat, 31 Oct 2009 10:17:04 -0500 Received: from mbx03.exg5.exghost.com ([169.254.1.128]) by ht01.exg5.exghost.com ([98.129.23.14]) with mapi; Sat, 31 Oct 2009 10:17:07 -0500 From: Peter Steele To: "freebsd-questions@freebsd.org" Date: Sat, 31 Oct 2009 10:17:05 -0500 Thread-Topic: system() call causes core dump Thread-Index: AcpaPTS/E6KMR1pTSfCxV1aPDwIr/Q== Message-ID: <7B9397B189EB6E46A5EE7B4C8A4BB7CB327D117F@MBX03.exg5.exghost.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: system() call causes core dump X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2009 15:17:09 -0000 I have an application running a number of threads. I've had recent instance= s where the code below is causing a core dump to occur: char fstatCmd[200]; char *fstatOut =3D "/tmp/fstat.out"; sprintf(fstatCmd, "fstat | grep -v USER | wc -l >%s", fstatOut); rc =3D system(fstatCmd); The call is simply intended to get a count of the current open handles. The= system call though causes a core: #0 0x0000000801058307 in _spinunlock () from /lib/libthr.so.3 #1 0x00000008011d0afb in _malloc_postfork () from /lib/libc.so.7 #2 0x000000080105c5fb in fork () from /lib/libthr.so.3 #3 0x0000000801191aae in system () from /lib/libc.so.7 #4 0x00000008010553aa in system () from /lib/libthr.so.3 #5 0x000000000040b6f9 in mythread at myapp.c:461 #6 0x0000000801056a88 in pthread_getprio () from /lib/libthr.so.3 There appears to be some kind of thread-safe issue going on. I have a numbe= r of threads that are monitoring various items, waking up a differing inter= vals to do their respective tasks. Do I need to put in a global mutex so th= at the threads never attempt to make simultaneous system() calls? Curiously= , only this particular system() call appears to be causing a core.