• 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: How to assure NSTask termination when parent dies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to assure NSTask termination when parent dies


  • Subject: Re: How to assure NSTask termination when parent dies
  • From: Greg Guerin <email@hidden>
  • Date: Fri, 13 Aug 2010 14:32:22 -0700

Process group code:

	// launch the task
    	[task launch];

pid_t group = setsid();
if (group == -1) {
NSLog(@"setsid() == -1");
group = getpgrp();
}
if (setpgid([task processIdentifier], group) == -1) {
NSLog(@"unable to put task into same group as self: errno = %i", errno);
}

The current process-group id is inherited across fork() and execve() - see their respective man pages. So if you reorder the operations so setsid() occurs before [task launch], then the child inherits automatically.


This doesn't mean the child can't change its own pgid/sid. And since you mention a shell, it's not unusual for shells to do exactly that.

  -- GG

_______________________________________________

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


  • Follow-Ups:
    • Re: How to assure NSTask termination when parent dies
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: iPhone app with searchable text that highlights
  • Next by Date: Re: Using NSPredicateEditor with core data
  • Previous by thread: Re: How to assure NSTask termination when parent dies
  • Next by thread: Re: How to assure NSTask termination when parent dies
  • Index(es):
    • Date
    • Thread