terminal: Use forkpty()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-11-25 12:18:48 +01:00
parent 5bb4321134
commit 92ab403687
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -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);