]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
setsid() and set controlling terminal for real /sbin/init
authorHarald Hoyer <harald@redhat.com>
Mon, 18 May 2009 11:57:51 +0000 (13:57 +0200)
committerHarald Hoyer <harald@redhat.com>
Mon, 18 May 2009 12:01:49 +0000 (14:01 +0200)
enables job control in the test images

switch_root.c

index 1db062d86622d2bf9a1ba0bf9251e8aac8e89136..ef7a0fb5da7bc5d2b9c66becded6763b8279731f 100644 (file)
@@ -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);
 }