Re: Quitting all active applications
Re: Quitting all active applications
- Subject: Re: Quitting all active applications
- From: "Michael Ash" <email@hidden>
- Date: Fri, 29 Aug 2008 12:24:40 -0400
On Thu, Aug 28, 2008 at 1:52 PM, Martin Stoufer <email@hidden> wrote:
> I had always naively assumed that all the some *Framework underneath an app
> was setting up signal handlers for you with default behaviours. If this
> isn't the case, then yes any killall approach will cause loss of data.
>
> Now I'm interested into finding out why this isn't the case.
Signals are a very poor mechanism for this. Apple Events provide two
important semantics:
1) They allow for an "I'm finished" reply. This allows the sender to
find out when the target is done with its business, so that it can
allow the sender to take a tenth of a second or a hundred seconds as
it needs.
2) They allow for an "I'm not ready to quit yet" reply. You'll see
this in action if you try to log out when you have unsaved documents
in an application, and you click Cancel when it asks you whether you
want to save.
Signals don't support either of these. For #1, the standard technique
is to do a SIGTERM, wait one second, then do a SIGKILL to anybody
who's still left alive. This is less than ideal for what should be
obvious reasons. For #2, the possibility that a target might abort the
action is simply ignored. Targets die when they are killed, end of
story.
Consider what happens when you send a quit Apple Event to TextEdit
when you have an unsaved document open. You get a nice window asking
if you want to save, and letting you cancel. Now compare with what
happens when you send SIGTERM to pico or emacs with an unsaved
document open. They terminate instantaneously and take all of your
work down with them.
Now, there's nothing preventing the frameworks from installing a
handler for SIGTERM and closing down more gracefully. But the
convention is for SIGTERM to kill you very quickly, and a process is
only expected to clean up critical resources that might otherwise be
corrupted. Since a mechanism already exists for the "user-friendly
quit", there's not too much point in changing the meaning of SIGTERM
as well.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden