Re: pthread - system() blocking
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Feb 28, 2011, at 18:20 , Stephen J. Butler wrote:
On Mon, Feb 28, 2011 at 5:13 PM, Mark E. Armstrong <Mark.Armstrong@soleratec.com> wrote:
In a pthread application, I need to call system() to execute an external program. When system() is called in a non-main thread, any other calls to system() are blocked until the previous call has returned. How do we work around the blocking?
Are you sure you aren't just seeing the effects of output buffering? That would be my first guess at what's happening... not that system() is being serialized.
But if that IS actually the case, you can always fork/exec yourself.
The system() call definitely blocks and is definitely serial. It will also override your signal handling for SIGINT, SIGQUIT and SIGCHLD. It's really just a simple convenience call for doing very simple shell execs. If you want to run things in parallel, you'll have to fork/exec and then wait on the children for exit information (which you can do using any of kqueue(), select() or dispatch sources very easily and without blocking). _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Jason Coco