terminal: Use forkpty()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5bb4321134
commit
92ab403687
@ -54,34 +54,14 @@ Result<void> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user