diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-10-01 10:09:05 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-10-01 10:09:05 -0400 |
commit | 80ac731c907c04f60148a696162cb95d7cedc90a (patch) | |
tree | 7fe33a8ec3ec7d27db1beffa393cedc2a21d8e6a /util.c | |
parent | 04445b6bff02da758a87a48c19ee4963aba62f15 (diff) | |
download | bfs-80ac731c907c04f60148a696162cb95d7cedc90a.tar.xz |
util: Move redirect() and isopen() to main.c
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 28 |
1 files changed, 0 insertions, 28 deletions
@@ -92,34 +92,6 @@ error: return NULL; } -bool isopen(int fd) { - return fcntl(fd, F_GETFD) >= 0 || errno != EBADF; -} - -int redirect(int fd, const char *path, int flags, ...) { - mode_t mode = 0; - if (flags & O_CREAT) { - va_list args; - va_start(args, flags); - - // Use int rather than mode_t, because va_arg must receive a - // fully-promoted type - mode = va_arg(args, int); - - va_end(args); - } - - int ret = open(path, flags, mode); - - if (ret >= 0 && ret != fd) { - int orig = ret; - ret = dup2(orig, fd); - close(orig); - } - - return ret; -} - int dup_cloexec(int fd) { #ifdef F_DUPFD_CLOEXEC return fcntl(fd, F_DUPFD_CLOEXEC, 0); |