Re: Terminating an Application ?
Re: Terminating an Application ?
- Subject: Re: Terminating an Application ?
- From: Brian Webster <email@hidden>
- Date: Mon, 4 Nov 2002 21:31:23 -0600
On Monday, November 4, 2002, at 06:26 PM,
email@hidden wrote:
My question is, are there any hidden problems associated with
terminating an
OS X app in this fashion ?
Terminating an application using kill will mean that that application
won't have any chance to perform cleanup that it normally does on quit,
plus the user will not have an opportunity to keep any unsaved changes.
The "polite" way to quit an application is to send it an Apple event.
Here's a short (unchecked) example of how to do that, building on the
code that you wrote using NSWorkspace:
AEDesc addressDesc;
AppleEvent event, reply;
OSErr err;
pid_t pid;
pid = [[ApplInfo objectForKey:NSApplicationProcessIdentifier] intValue];
err = AECreateDesc(typeKernelProcessID, &pid, sizeof(pid_t),
&addressDesc);
if (err == noErr)
err = AECreateAppleEvent(kCoreEventClass, kAEQuitApplication,
&addressDesc, kAutoGenerateReturnID, kAnyTransactionID, &event);
if (err == noErr)
err = AESend(&event, &reply, kAENoReply, kAENormalPriority,
kAEDefaultTimeout);
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.