On Thu, Dec 18, 2008 at 3:30 AM, Jean-Daniel Dupas
<devli...@shadowlab.org> wrote:
>
> Le 18 déc. 08 à 04:55, Michael Ash a écrit :
>
>> On Wed, Dec 17, 2008 at 2:32 PM, Greg Parker <gpar...@apple.com> wrote:
>>>
>>> On Dec 16, 2008, at 7:22 PM, Michael Ash wrote:
>>>>
>>>> On Tue, Dec 16, 2008 at 8:02 PM, Chris Idou <idou...@yahoo.com> wrote:
>>>>>
>>>>> Is there any Cocoa and/or Carbon interface to UNIX signals?
>>>>
>>>> Nope. It's pretty easy to set up a signal handler that can call back
>>>> to a Cocoa/CoreFoundation runloop though, by having it write to a pipe
>>>> or mach port which the runloop monitors.
>>>
>>> Be warned that, to a close approximation, your code isn't allowed to do
>>> anything inside the signal handler itself. This includes sending any
>>> Objective-C messages to any object. (objc_msgSend may take locks. If the
>>> signal is interrupting a thread that already holds those locks, you're
>>> stuck.)
>>>
>>> The official list of functions you can call is in the sigaction man page.
>>> Some Mach functions are also safe, but I don't know of an official list
>>> of
>>> which ones.
>>
>> Yep, that's a very good point. To use my suggestion, your signal
>> handler must do *nothing* but write to the pipe or mach port, and it
>> must ensure that the write is guaranteed non-blocking. This isn't too
>> hard, but it must be adhered to rigidly.
>
> Although, as mention by Greg Parker, I didn't find doc that guarantee that
> using mach_msg() is safe in a signal. (but Apple is using it in securityd,
> so I'm not worry about it).

Good luck finding *any* documentation about the mach functions.
(Seriously. If you know of good Apple-provided ones, I'd like to
know!) Normally I'd be wary, but in this case not having documentation
is simply par for the course.

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to