fish-shell/src/fds.cpp

27 lines
460 B
C++
Raw Normal View History

/** Facilities for working with file descriptors. */
#include "config.h" // IWYU pragma: keep
#include "fds.h"
#include <errno.h>
#include <unistd.h>
#include "wutil.h"
void autoclose_fd_t::close() {
if (fd_ < 0) return;
exec_close(fd_);
fd_ = -1;
}
void exec_close(int fd) {
assert(fd >= 0 && "Invalid fd");
while (close(fd) == -1) {
if (errno != EINTR) {
wperror(L"close");
break;
}
}
}