2
0
Fork 0
mirror of https://github.com/fish-shell/fish-shell synced 2025-02-13 04:33:33 +00:00

iothread's notify pipes to use make_autoclose_pipes

This allows it to take advantage of the upcoming high-range fd changes.
This commit is contained in:
ridiculousfish 2021-02-02 18:35:49 -08:00
parent 4b4bf541d1
commit 6c4f2622ef

View file

@ -154,17 +154,14 @@ struct notify_pipes_t {
/// \return the (immortal) set of pipes used for notifying of completions.
static const notify_pipes_t &get_notify_pipes() {
static const notify_pipes_t s_notify_pipes = [] {
int pipes[2] = {0, 0};
assert_with_errno(pipe(pipes) != -1);
set_cloexec(pipes[0]);
set_cloexec(pipes[1]);
// Mark both ends as non-blocking.
for (int fd : pipes) {
if (make_fd_nonblocking(fd)) {
wperror(L"fcntl");
}
auto pipes = make_autoclose_pipes({});
if (!pipes) {
DIE_WITH_ERRNO("Unable to create iothread notify pipes");
}
return notify_pipes_t{pipes[0], pipes[1]};
// Mark both ends as non-blocking.
if (make_fd_nonblocking(pipes->read.fd())) wperror(L"fcntl");
if (make_fd_nonblocking(pipes->write.fd())) wperror(L"fcntl");
return notify_pipes_t{pipes->read.acquire(), pipes->write.acquire()};
}();
return s_notify_pipes;
}