Re: How to get scripting to work without NSApplication
Re: How to get scripting to work without NSApplication
- Subject: Re: How to get scripting to work without NSApplication
- From: David Remahl <email@hidden>
- Date: Mon, 10 Dec 2001 17:00:41 +0100
Someone said a few days ago, that the only thing that was safe to do from a
handler, was to switch a global variable...But if the darwin developers said
otherwise...
/ david
>
Jason,
>
>
I had exactly the same issue as you and was told not to use
>
any Cocoa calls in a signal handler. My solution was to create
>
an NSPipe, do a readInBackgroundAndNotify on the read end,
>
and then from the signal handler just do a write(2) directly
>
on the write-end file descriptor.
>
>
This works well, and I later saw on the Darwin developers
>
mailing list somebody recommending this writing-to-a-pipe
>
from a signal handler trick, so I guess it is pretty safe.
>
>
I.
>
>
On Monday, December 10, 2001, at 07:32 , Jason Bobier wrote:
>
>
> This is a background damon running as root. I only need to handle the
>
> AEQuit event so that I can cleanup our sdk before the damon is
>
> terminated.
>
>
>
> Currently I am catching SIGTERM and doing the cleanup there. I was told
>
> that this has issues though because cocoa can't handle being called from
>
> signal handlers.
>
>
>
> One thing that I did just notice though. NSNotificationCenter is
>
> thread-safe and re-entrant. Does this mean that I could send a
>
> notification to myself from a signal handler? If so, that would do the
>
> job.
>
>
>
> Thanx,
>
>
>
> Jason