Add the reset atexit handler right after setting the terminal to raw mode, so we...
[util-vserver.git] / src / vlogin.c
index 56a1df0..70a8aed 100644 (file)
@@ -209,6 +209,9 @@ void do_vlogin(int argc, char *argv[], int ind)
   /* set terminal to raw mode */
   terminal_raw();
 
+  /* reset terminal to its original mode */
+  atexit(terminal_reset);
+
   /* fork new pseudo terminal */
   if (openpty(&t.fd, &slave, NULL, NULL, NULL) == -1) {
     perror(ENSC_WRAPPERS_PREFIX "openpty()");
@@ -254,9 +257,6 @@ void do_vlogin(int argc, char *argv[], int ind)
 
   strncpy(argv[0], "login", n);
 
-  /* reset terminal to its original mode */
-  atexit(terminal_reset);
-
   /* we want a redraw */
   terminal_redraw();