mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-10 12:21:06 +08:00
27 lines
460 B
C++
27 lines
460 B
C++
![]() |
/** 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;
|
||
|
}
|
||
|
}
|
||
|
}
|