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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to