getty: explain when setsid() fails. no code changes
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 10 May 2014 22:00:52 +0000 (00:00 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 10 May 2014 22:00:52 +0000 (00:00 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
loginutils/getty.c

index 0f060ae6cd052359aba7e16d60fe227e4bbb97cd..4b1b73befd3f116df27d8cc86a02e14c866c6ad3 100644 (file)
@@ -556,6 +556,16 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
                        //      pid, getppid(),
                        //      getsid(0), getpgid(0));
                        bb_perror_msg_and_die("setsid");
+                       /*
+                        * When we can end up here?
+                        * Example: setsid() fails when run alone in interactive shell:
+                        *  # getty 115200 /dev/tty2
+                        * because shell's child (getty) is put in a new process group.
+                        * But doesn't fail if shell is not interactive
+                        * (and therefore doesn't create process groups for pipes),
+                        * or if getty is not the first process in the process group:
+                        *  # true | getty 115200 /dev/tty2
+                        */
                }
                /* Looks like we are already a session leader.
                 * In this case (setsid failed) we may still have ctty,