• 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: Terminating an Application ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Terminating an Application ?
      • From: Chris Ridd <email@hidden>
  • Prev by Date: Project Builder's tasty documentation searching
  • Next by Date: Re: advice on filtering TreeNode objects
  • Previous by thread: Terminating an Application ?
  • Next by thread: Re: Terminating an Application ?
  • Index(es):
    • Date
    • Thread