diff --git a/terminal/TerminalWidget.cpp b/terminal/TerminalWidget.cpp index aafe721b..e6a28f26 100644 --- a/terminal/TerminalWidget.cpp +++ b/terminal/TerminalWidget.cpp @@ -54,34 +54,14 @@ Result TerminalWidget::init(char* const* args) signal(SIGCHLD, sigchld_handler); int master; - int slave; - - int result = openpty(&master, &slave, nullptr, nullptr, nullptr); - if (result < 0) return err(errno); - - pid_t child = TRY(os::Process::fork()); + pid_t child = forkpty(&master, nullptr, nullptr, nullptr); + if (child < 0) return err(errno); if (child == 0) { - setsid(); - - close(master); - - ioctl(slave, TIOCSCTTY); - - dup2(slave, STDIN_FILENO); - dup2(slave, STDOUT_FILENO); - dup2(slave, STDERR_FILENO); - - tcsetpgrp(slave, getpid()); - - close(slave); - execv(args[0], args); _exit(127); } - close(slave); - m_pty = master; fcntl(master, F_SETFL, O_NONBLOCK);