From acbebb1ac5f966b6e3fbb9d11fde95408b4bdf52 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Mon, 9 Jan 2012 11:33:07 -0800 Subject: [PATCH] Explain use of fork() without exec() --- src/slurmd/slurmd/req.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/slurmd/slurmd/req.c b/src/slurmd/slurmd/req.c index f312f882487..add5e0374b0 100644 --- a/src/slurmd/slurmd/req.c +++ b/src/slurmd/slurmd/req.c @@ -2474,7 +2474,16 @@ _rpc_file_bcast(slurm_msg_t *msg) /* The child actually performs the I/O and exits with * a return code, do not return! */ - /* set the child's group list */ + /*********************************************************************\ + * NOTE: It would be best to do an exec() immediately after the fork() + * in order to help prevent a possible deadlock in the child process + * due to locks being set at the time of the fork and being freed by + * the parent process, but not freed by the child process. Performing + * the work inline is done for simplicity. Note that the logging + * performed by error() should be safe due to the use of + * atfork_install_handlers() as defined in src/common/log.c. + * Change the code below with caution. + \*********************************************************************/ if (setgroups(ngroups, groups) < 0) { error("sbcast: uid: %u setgroups: %s", req_uid, strerror(errno)); -- GitLab