Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Oct 2009 10:17:05 -0500
From:      Peter Steele <psteele@maxiscale.com>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   system() call causes core dump
Message-ID:  <7B9397B189EB6E46A5EE7B4C8A4BB7CB327D117F@MBX03.exg5.exghost.com>

next in thread | raw e-mail | index | archive | help
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.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7B9397B189EB6E46A5EE7B4C8A4BB7CB327D117F>