bool success;
int ret, pid;
char *errctx;
+ struct termios tios;
+ bool tty;
ret = lls_check_arg_count(sublpr, 1, INT_MAX, &errctx);
if (ret < 0)
: dflt_cmd[n];
argv[N - 1] = NULL;
clean_env();
+ tty = false;
+ if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
+ if (tcgetattr(STDIN_FILENO, &tios) >= 0)
+ tty = true;
+ }
success = xexec(argv, NULL);
+ if (tty) { /* reset terminal settings */
+ /*
+ * First give up the controlling terminal. Without this, the
+ * command gets SIGSTOP and goes to the background. We ignore
+ * errors here because nobody cares about a messed up terminal.
+ */
+ ioctl(STDIN_FILENO, TIOCNOTTY);
+ tcsetattr(STDIN_FILENO, TCSAFLUSH, &tios);
+ }
free(argv);
return success;
}