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

Daniel Lezcano daniel.lezcano at free.fr
Thu Jun 10 19:53:48 UTC 2010


On 06/09/2010 07:56 PM, Ferenc Wagner wrote:
> Signed-off-by: Ferenc Wagner<wferi at niif.hu>
> ---
>   src/lxc/start.c |   17 +++++++++++++++++
>   1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/src/lxc/start.c b/src/lxc/start.c
> index b69ac88..7bbcf5a 100644
> --- a/src/lxc/start.c
> +++ b/src/lxc/start.c
> @@ -463,6 +463,7 @@ int lxc_spawn(struct lxc_handler *handler)
>   	int clone_flags;
>   	int failed_before_rename = 0;
>   	const char *name = handler->name;
> +	int ctty;
>
>   	if (lxc_sync_init(handler))
>   		return -1;
> @@ -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 ?

>   	/* Tell the child to continue its initialization and wait for
>   	 * it to exec or return an error
>   	 */
>    





More information about the lxc-devel mailing list