+ /* Make new session and process group */
+ setsid();
+
+ /* Open the child's side of the tty */
+ /* NB: setsid() disconnects from any previous ctty's. Therefore
+ * we must open child's side of the tty AFTER setsid! */
+ close(0);
+ xopen(tty_name, O_RDWR); /* becomes our ctty */
+ xdup2(0, 1);
+ xdup2(0, 2);
+ tcsetpgrp(0, pid); /* switch this tty's process group to us */
+
+ /* The pseudo-terminal allocated to the client is configured to operate
+ * in cooked mode, and with XTABS CRMOD enabled (see tty(4)) */
+ tcgetattr(0, &termbuf);
+ termbuf.c_lflag |= ECHO; /* if we use readline we dont want this */
+ termbuf.c_oflag |= ONLCR | XTABS;
+ termbuf.c_iflag |= ICRNL;
+ termbuf.c_iflag &= ~IXOFF;
+ /*termbuf.c_lflag &= ~ICANON;*/
+ tcsetattr_stdin_TCSANOW(&termbuf);
+
+ /* Uses FILE-based I/O to stdout, but does fflush_all(),
+ * so should be safe with vfork.
+ * I fear, though, that some users will have ridiculously big
+ * issue files, and they may block writing to fd 1,
+ * (parent is supposed to read it, but parent waits
+ * for vforked child to exec!) */
+ print_login_issue(G.issuefile, tty_name);
+
+ /* Exec shell / login / whatever */
+ login_argv[0] = G.loginpath;
+ login_argv[1] = NULL;
+ /* exec busybox applet (if PREFER_APPLETS=y), if that fails,
+ * exec external program.
+ * NB: sock is either 0 or has CLOEXEC set on it.
+ * fd has CLOEXEC set on it too. These two fds will be closed here.
+ */
+ BB_EXECVP(G.loginpath, (char **)login_argv);
+ /* _exit is safer with vfork, and we shouldn't send message
+ * to remote clients anyway */
+ _exit(EXIT_FAILURE); /*bb_perror_msg_and_die("execv %s", G.loginpath);*/