From 038e5385866a507726965a667fa0c7ef0497a9c2 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 22 Jun 2018 23:21:34 -0400 Subject: [PATCH] libcom_err: handle error case when FD_CLOEXEC can't be set on debug FILE Fixes-Coverity-Bug: 1049142 Signed-off-by: Theodore Ts'o --- lib/et/error_message.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/et/error_message.c b/lib/et/error_message.c index 5dd8aa658..bd18be781 100644 --- a/lib/et/error_message.c +++ b/lib/et/error_message.c @@ -257,7 +257,14 @@ static void init_debug(void) if (fd >= 0) { flags = fcntl(fd, F_GETFD); if (flags >= 0) - fcntl(fd, F_SETFD, flags | FD_CLOEXEC); + flags = fcntl(fd, F_SETFD, flags | FD_CLOEXEC); + if (flags < 0) { + fprintf(debug_f, "Couldn't set FD_CLOEXEC " + "on debug FILE: %s\n", strerror(errno)); + fclose(debug_f); + debug_f = NULL; + debug_mask = DEBUG_INIT; + } } #endif } else -- 2.39.2