Re: Objective-C in signal handlers (was Re: Inter process communication question)
Re: Objective-C in signal handlers (was Re: Inter process communication question)
- Subject: Re: Objective-C in signal handlers (was Re: Inter process communication question)
- From: Terry Glass <email@hidden>
- Date: Wed, 5 Feb 2003 19:03:55 -0600
On Wednesday, February 5, 2003, at 06:24 PM, Greg Parker wrote:
Don't do that. Sending Objective-C messages from inside a signal
handler is unsafe. If the signal happens to arrive at the wrong
time, the Objective-C runtime will deadlock because the signal
handler will try to grab a lock that's already held by the
interrupted thread.
I said in my original message that I knew how I was handling SIGHUP
was bad.
In general, you can't do anything inside a signal handler other than
write() to a pipe or set a global variable that some other thread is
watching. exit() is definitely unsafe because it might call atexit()
handlers; use _exit() instead. unlink() might be safe if it's just a
single system call, but I'm not sure about that.
For SIGTERM, I was working according to section 10.6 of APUE, where
Stevens states that POSIX.1 specifies that unlink must be reentrant. I
assume that OS X is mostly POSIX compliant?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.