• 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: running bash script...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: running bash script...


  • Subject: Re: running bash script...
  • From: Nicko van Someren <email@hidden>
  • Date: Thu, 27 Jan 2005 17:43:13 +0000

On 27 Jan 2005, at 17:07, Martha I. Espinosa wrote:

Good Morning,

It's afternoon here. You Americans are so parochial :-)

I want to run a bash script at the end of my application when the user clicks on the "quit" button.... Should I use NSTask?

That's a good quesiton. In most cases you would almost certainly want to run sub-tasks in an NSTask. However if you start an NSTask just before termination and don't wait for it to complete then I think you may find it will get killed when the parent process (your application) terminates. So what you probably want to do is implement applicationShouldTerminate: in the application delegate, start the task there, register for the NSTaskDidTerminateNotification notification, return NSTerminateLater, then catch the notification and call replyToApplicationShouldTerminate: on the application to complete the termination process.


The above is probably the "right" way to do what you want, but it's a bit of a pain. Alternatively you could just call system() from the C stdlib.h and hope that your shell script never hangs.

	Cheers,
		Nicko


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >running bash script... (From: "Martha I. Espinosa" <email@hidden>)

  • Prev by Date: Re: May I pack java in a dylib?
  • Next by Date: Re: May I pack java in a dylib?
  • Previous by thread: running bash script...
  • Next by thread: [ANN] New F-Script version - Introspection and scripting for Cocoa
  • Index(es):
    • Date
    • Thread