From: Jérémie Galarneau Date: Thu, 5 Mar 2020 21:52:32 +0000 (-0500) Subject: Fix: sessiond: occasional badfd error on repeated SIGTERM X-Git-Tag: v2.11.3~4 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=ba58cc31d8b9b4bfa07d965925c70e0ceb632e47 Fix: sessiond: occasional badfd error on repeated SIGTERM The session daemon occasionally prints the following messages when it received multiple SIGTERM signals: PERROR - 16:50:18.505585257 [49845/49845]: write poll pipe: Bad file descriptor (in notify_thread_pipe() at utils.c:35) This is caused by a (somewhat inevitable) race between the teardown of the daemon and the closing of its quit pipe. This happens more often when kernel modules take a long time to be unloaded and the user spams ctrl+c in the hope of convincing the daemon process to close faster since modules are unloaded after closing the quit pipe. Setting closed pipe fds to '-1' is safe anyway and is already handled by the notify_thread_pipe() util. Signed-off-by: Jérémie Galarneau Change-Id: If08a455c65055dcb56ffbad3703173e6a45cfba5 --- diff --git a/src/common/utils.c b/src/common/utils.c index 22fd33ea3..7041a713b 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -547,6 +547,7 @@ void utils_close_pipe(int *src) if (ret) { PERROR("close pipe"); } + src[i] = -1; } }