[lxc-devel] [PATCH 4/7] start child in its own process group, and put it into the foreground
Ferenc Wagner
wferi at niif.hu
Sun Jun 6 21:07:29 UTC 2010
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..851d383 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) {
+ 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");
+ }
+
/* Tell the child to continue its initialization and wait for
* it to exec or return an error
*/
--
1.6.5
More information about the lxc-devel
mailing list