diff --git a/src/util/subprocess.h b/src/util/subprocess.h index 29f6e8ffa7e..244a99957c7 100644 --- a/src/util/subprocess.h +++ b/src/util/subprocess.h @@ -346,10 +346,14 @@ namespace util void set_clo_on_exec(int fd, bool set = true) { int flags = fcntl(fd, F_GETFD, 0); + if (flags == -1) { + throw OSError("fcntl F_GETFD failed", errno); + } if (set) flags |= FD_CLOEXEC; else flags &= ~FD_CLOEXEC; - //TODO: should check for errors - fcntl(fd, F_SETFD, flags); + if (fcntl(fd, F_SETFD, flags) == -1) { + throw OSError("fcntl F_SETFD failed", errno); + } }