From 82ae6e0ce5422cdda8eba4a424f4abb4d559f7bb Mon Sep 17 00:00:00 2001 From: Mark Grondona <mgrondona@llnl.gov> Date: Mon, 1 May 2006 16:22:55 +0000 Subject: [PATCH] Send stderr to /dev/null instead of just closing it in io_close_all(). Otherwise log facility may still try to write to stderr which is either a closed descriptor, or some other open file (like a socket) --- src/slurmd/slurmstepd/io.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/slurmd/slurmstepd/io.c b/src/slurmd/slurmstepd/io.c index 2796c99e3e3..0f177ea258e 100644 --- a/src/slurmd/slurmstepd/io.c +++ b/src/slurmd/slurmstepd/io.c @@ -893,6 +893,7 @@ io_close_task_fds(slurmd_job_t *job) void io_close_all(slurmd_job_t *job) { + int devnull; #if 0 int i; for (i = 0; i < job->ntasks; i++) @@ -902,7 +903,17 @@ io_close_all(slurmd_job_t *job) /* No more debug info will be received by client after this point */ debug("Closing debug channel"); - close(STDERR_FILENO); + + /* + * Send stderr to /dev/null since debug channel is closing + * and log facility may still try to write to stderr. + */ + if ((devnull = open("/dev/null", O_RDWR)) < 0) { + error("Unable to open /dev/null: %m"); + } else { + if (dup2(devnull, STDERR_FILENO) < 0) + error("Unable to dup /dev/null onto stderr\n"); + } /* Signal IO thread to close appropriate * client connections -- GitLab