diff --git a/src/common/log.c b/src/common/log.c index 1e6cbdd66c707cd7c5e4afc8b54e013440b3498d..e85499a93d3d706cd68c6427068343f53e3b4b4b 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -73,6 +73,7 @@ #include <slurm/slurm_errno.h> #include "src/common/log.h" +#include "src/common/fd.h" #include "src/common/macros.h" #include "src/common/safeopen.h" #include "src/common/xassert.h" @@ -239,8 +240,13 @@ _log_init(char *prog, log_options_t opt, log_facility_t fac, char *logfile ) log->logfp = fp; } - if (log->logfp && (fileno(log->logfp) < 0)) - log->logfp = NULL; + if (log->logfp) { + int fd; + if ((fd = fileno(log->logfp)) < 0) + log->logfp = NULL; + else + fd_set_close_on_exec(fd); + } log->initialized = 1; out: diff --git a/src/slurmd/slurmstepd/task.c b/src/slurmd/slurmstepd/task.c index fab48cf39c1cb11dd2b3fae4430fbb7024867ef2..a54c7d69cd3b638e708e4fbd8841dff332d51a9a 100644 --- a/src/slurmd/slurmstepd/task.c +++ b/src/slurmd/slurmstepd/task.c @@ -361,14 +361,13 @@ exec_task(slurmd_job_t *job, int i, int waitfd) job->env[0] = (char *)NULL; } - log_fini(); execve(task->argv[0], task->argv, job->env); /* * print error message and clean up if execve() returns: */ - fprintf(stderr, "Unable to run executable \"%s\"\n", task->argv[0]); - exit(42); + error("execve(): %s: %m", task->argv[0]); + exit(errno); } static void