From edc6342c5106959a01f5e2d08a7cb95b3c24de9c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 2 Apr 2023 22:21:29 +0200 Subject: [PATCH] Minor close-on-exec fix. --- httpinput.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpinput.cpp b/httpinput.cpp index a972fa2..75cf99b 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -80,7 +80,9 @@ HTTPInput::HTTPInput(const InputProto &serialized) { // Set back the close-on-exec flag for the socket. // (This can't leak into a child, since we haven't been started yet.) - fcntl(sock, F_SETFD, O_CLOEXEC); + if (sock != -1) { + fcntl(sock, F_SETFD, O_CLOEXEC); + } pending_data.resize(serialized.pending_data().size()); memcpy(&pending_data[0], serialized.pending_data().data(), serialized.pending_data().size()); -- 2.39.2