[launchd-dev] libdispatch threads, blocked SIGINT and child process
tclement at intego.com
Thu Dec 2 23:59:18 PST 2010
Oops, I posted this to the wrong mailing-list, sorry.
On 2 déc. 2010, at 15:56, Thomas Clement wrote:
> I have encountered a strange behavior when using libdispatch (OS X 10.6.5). I'm not sure if there is a bug in libdispatch or else what the correct fix is for me.
> I found myself in the situation of doing a fork/exec/waitpid from a libdispatch thread, the child process waiting for user input, then doing ctrl-c in my Terminal window. I would expect the child process to also be terminated, however the child process is still running, consuming lots of cpu (and its ppid is now 1 which is weird).
> I have noticed that libdispatch calls pthread_sigmask() when creating new threads blocking many signals. I have found that calling pthread_sigmask() in my dispatch_asynced code to unblock the SIGINT signal fixes the issue (the child process is also terminated when doing a ctrl-c in my Terminal window).
> You can reproduce the issue using the attached sample code (which uses launchctl as the child process but it could be anything else). You can run the process from the Terminal window (./sigdispatch_br) then doing ctrl-c and watching the child process from a "top".
> So, what do you guys think?
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
More information about the launchd-dev