• 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: Quit helper app when main app terminates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quit helper app when main app terminates


  • Subject: Re: Quit helper app when main app terminates
  • From: John Harte <email@hidden>
  • Date: Thu, 12 Jul 2012 15:08:28 -0400

On Jul 12, 2012, at 12:33 PM, Jerry Krinock wrote:

> What is the best way to make a helper app quit when the associated main app quits (or crashes)?  No harm will be done if it keeps running for a minute or so.

I create a pthread with this code

	pid_t ppid = getppid (); 	// get parent pid

	if (ppid > 1) {
		int kq = kqueue ();
		if (kq != -1) {
			struct kevent procEvent;	// wait for parent to exit
			EV_SET (&procEvent,		// kevent
					ppid,			// ident
					EVFILT_PROC,	// filter
					EV_ADD,			// flags
					NOTE_EXIT,		// fflags
					0,				// data
					0);				// udata

			kevent (kq, &procEvent, 1, &procEvent, 1, 0);
		}
	}
	exit (0);

_______________________________________________

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

References: 
 >Quit helper app when main app terminates (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Quit helper app when main app terminates
  • Next by Date: Re: Quit helper app when main app terminates
  • Previous by thread: Re: Quit helper app when main app terminates
  • Next by thread: Re: Quit helper app when main app terminates
  • Index(es):
    • Date
    • Thread