From: Harald Hoyer Date: Mon, 18 May 2009 11:57:51 +0000 (+0200) Subject: setsid() and set controlling terminal for real /sbin/init X-Git-Tag: 0.1~264 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=afc3ed92cccfc4c08d5602f8a62572a7111b3e01;p=thirdparty%2Fdracut.git setsid() and set controlling terminal for real /sbin/init enables job control in the test images --- diff --git a/switch_root.c b/switch_root.c index 1db062d86..ef7a0fb5d 100644 --- a/switch_root.c +++ b/switch_root.c @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) char *newroot = argv[1]; char *init = argv[2]; char **initargs = &argv[2]; - + if (newroot == NULL || newroot[0] == '\0' || init == NULL || init[0] == '\0' ) { usage(stderr); @@ -184,6 +184,12 @@ int main(int argc, char *argv[]) } if (access(initargs[0], X_OK)) fprintf(stderr, "WARNING: can't access %s\n", initargs[0]); + + /* get session leader */ + setsid(); + /* set controlling terminal */ + ioctl (0, TIOCSCTTY, 1); + execv(initargs[0], initargs); }