• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa & signal handlers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa & signal handlers


  • Subject: Re: Cocoa & signal handlers
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 10 Dec 2001 16:15:42 -0800

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.

However, I cannot myself guarantee that either a write() call or sending a Mach message is safe during the execution of a signal handler.

Douglas Davidson


  • Follow-Ups:
    • Re: Cocoa & signal handlers
      • From: Ingvar Nedrebo <email@hidden>
References: 
 >Re: Cocoa & signal handlers (From: Greg Parker <email@hidden>)

  • Prev by Date: Re: [ANN] New NSTask sample
  • Next by Date: Re: [ANN] New NSTask sample
  • Previous by thread: Re: Cocoa & signal handlers
  • Next by thread: Re: Cocoa & signal handlers
  • Index(es):
    • Date
    • Thread