mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
job-control: set CLOEXEC on pty processes. #5986
Before this change, new processes started with libuv prevented SIGHUP from reaching pty processes (by keeping the ptmx file descriptor open).
This commit is contained in:

committed by
Justin M. Keyes

parent
ad1884be0d
commit
f6946c68ae
@@ -73,6 +73,13 @@ int pty_process_spawn(PtyProcess *ptyproc)
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Other jobs and providers should not get a copy of this file descriptor.
|
||||
if (os_set_cloexec(master) == -1) {
|
||||
status = -errno;
|
||||
ELOG("Failed to set CLOEXEC on ptmx file descriptor");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (proc->in
|
||||
&& (status = set_duplicating_descriptor(master, &proc->in->uv.pipe))) {
|
||||
goto error;
|
||||
@@ -215,14 +222,24 @@ static int set_duplicating_descriptor(int fd, uv_pipe_t *pipe)
|
||||
ELOG("Failed to dup descriptor %d: %s", fd, strerror(errno));
|
||||
return status;
|
||||
}
|
||||
|
||||
if (os_set_cloexec(fd_dup) == -1) {
|
||||
status = -errno;
|
||||
ELOG("Failed to set CLOEXEC on duplicate fd");
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = uv_pipe_open(pipe, fd_dup);
|
||||
if (status) {
|
||||
ELOG("Failed to set pipe to descriptor %d: %s",
|
||||
fd_dup, uv_strerror(status));
|
||||
close(fd_dup);
|
||||
return status;
|
||||
goto error;
|
||||
}
|
||||
return status;
|
||||
|
||||
error:
|
||||
close(fd_dup);
|
||||
return status;
|
||||
}
|
||||
|
||||
static void chld_handler(uv_signal_t *handle, int signum)
|
||||
|
Reference in New Issue
Block a user