[lxc-devel] [PATCH 1/5] start child in its own process group, and put it into the foreground

Matt Helsley matthltc at us.ibm.com
Fri Jun 11 21:26:49 UTC 2010


On Thu, Jun 10, 2010 at 11:57:20PM +0200, Ferenc Wagner wrote:
> Daniel Lezcano <daniel.lezcano at free.fr> writes:
> 
> > On 06/09/2010 07:56 PM, Ferenc Wagner wrote:
> >
> >> @@ -509,6 +510,22 @@ int lxc_spawn(struct lxc_handler *handler)
> >>   		}
> >>   	}
> >>
> >> +	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 ?
> 
> I can't think of one.  It shouldn't matter, as long as the child can
> open /dev/tty.

I think shells implementing job control do it in the parent (shell) 
rather than the child (job) purely out of convention. It might be good
to follow a similar convention even if lxc is not, strictly speaking, a 
shell.

Cheers,
	-Matt Helsley




More information about the lxc-devel mailing list