Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Mar 2007 15:25:15 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        Kip Macy <kip.macy@gmail.com>, John-Mark Gurney <gurney_j@resnet.uoregon.edu>, freebsd-threads@freebsd.org, freebsd-arch@freebsd.org, Max Laier <max@love2party.net>
Subject:   Re: Multithreaded qsort(3)
Message-ID:  <20070318202515.GF64778@dan.emsphone.com>
In-Reply-To: <20070318134900.GA98260@kobe.laptop>
References:  <45F906ED.8070100@aueb.gr> <200703151827.39963.max@love2party.net> <20070318053307.GC73385@funkthat.com> <b1fa29170703172343u2e54722cjfaf52ec7d4aed1c@mail.gmail.com> <20070318134900.GA98260@kobe.laptop>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Mar 18), Giorgos Keramidas said:
> On 2007-03-17 23:43, Kip Macy <kip.macy@gmail.com> wrote:
> > Reminds me of how Solaris blindly uses vfork for implementing
> > system(3). It was very easy for a naive user (me) to call system
> > from a multi-threaded python application. I had numerous failures
> > that were impossible to track back to system(3).
> 
> It seems like an 'obvious' optimization, though.  vfork() will block
> the parent process until the child runs exec(), and the whole purpose
> of system is to exec() a shell and run an external command.
> 
> Can you elaborate on the problems you were seeing?  It sounds like
> something both interesting and educational :)

Btw - the Solaris 10 system manpage only mentions signal interactions
as the cause for MT-unsafeness:

    "The system() function manipulates the signal handlers for SIGINT,
     SIGQUIT, and SIGCHLD.  It is therefore not safe to call system()
     in a multithreaded process, since some other thread that
     manipulates these signal handlers and a thread that concurrently
     calls system() can interfere with each other in a destructive
     manner.  If, however, no such other thread is active, system() can
     safely be called concurrently from multiple threads.  See
     popen(3C) for an alternative to system() that is thread-safe."

It looks like there were some vfork-related system() bugs in older
versions of Solaris, but they appear to have been fixed:
http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4332595

-- 
	Dan Nelson
	dnelson@allantgroup.com



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