Re: Quit helper app when main app terminates
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