Re: Cocoa & signal handlers
Re: Cocoa & signal handlers
- Subject: Re: Cocoa & signal handlers
- From: Ingvar Nedrebo <email@hidden>
- Date: Tue, 11 Dec 2001 12:05:44 +0000
On Tuesday, December 11, 2001, at 12:15 , Douglas Davidson wrote:
On Monday, December 10, 2001, at 03:55 PM, Greg Parker wrote:
My understanding from the documentation of readInBackgroundAndNotify
was that it does the read in a separate thread -- on the face
of it it looks fairly safe to do a single system call in a signal
handler, provided of course that the write doesn't block, but
I'm only writing 4 bytes (the signal number).
You may be right, the write() method may be safe even if waking the run
loop from the signal handler is not. -readInBackgroundAndNotify
probably
works like CFSocket with a second thread running select(). That thread
does need to wake up the run loop, but it doesn't need to talk to the
run loop during the signal handler.
Yes, it is something along these lines. Another option would be to use
CFSocket rather than NSFileHandle to do the receiving; that may be
somewhat lighter-weight. Another alternative that might seem natural
would be to use a Mach message rather than a BSD pipe, and receive it
with a CFMachPort.
I have looked into Mach ports, but from the angle that a rather more
elegant approach to communicating with a server would be to use
Distributed
Objects with a command-line tool to send messages to the server --
signals
are so last century :-) I will use DO for future projects, but it was a
bit overkill
for the daemon in question.
I.