On Thu, 2010-06-10 at 21:53 +0200, Daniel Lezcano wrote: > > + if (setpgid(handler->pid, 0)) { > > + SYSERROR("failed to create new process group"); > > + goto out_delete_net; > > + } > > + DEBUG("created new process group %d", handler->pid); > > + ctty = open("/dev/tty", O_RDONLY); > > + if (ctty != -1) { > > + int ret = tcsetpgrp(ctty, handler->pid); > > + close(ctty); > > + if (ret) { > > + SYSERROR("failed to set terminal foreground > process group"); > > + goto out_delete_net; > > + } > > + DEBUG("set terminal foreground process group"); > > + } > > > > Is there a particular reason to do that from the parent and not from > the > child ? >
Yes, because otherwise the new process group creation would be racy from the parent POV. It's important because there's a window between the call to setpgid() and the call to tcsetpgrp() where the child won't receive tty signals, for example: it's up to the parent to forward signals to the new process group in this case. Usually, both the parent and the child call setpgid() to ensure they have a consistent view, without the need to be synchronized. -- Gregory Kurz gk...@fr.ibm.com Software Engineer @ IBM/Meiosys http://www.ibm.com Tel +33 (0)534 638 479 Fax +33 (0)561 400 420 "Anarchy is about taking complete responsibility for yourself." Alan Moore. ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel