From 2d0621a197ac3529b040dcde4ac898ef93a5421c Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Wed, 2 Jul 2008 16:34:13 +0000 Subject: [PATCH] tweak user env loading logic to prevent indefinite hang of slurmd or salloc and Moab daemons --- src/common/env.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common/env.c b/src/common/env.c index 2edeb49f246..050c513523b 100644 --- a/src/common/env.c +++ b/src/common/env.c @@ -1446,10 +1446,21 @@ char **env_array_user_default(const char *username, int timeout, int mode) } } close(fildes[0]); - kill(-child, 9); - if (waitpid((pid_t)-1, &rc, WNOHANG)) - waitpid((pid_t)-1, &rc, WNOHANG); /* left from previous runs */ - + for (config_timeout=0; ; config_timeout++) { + kill(-child, 9); + if (config_timeout) + sleep(1); + if (waitpid(child, &rc, WNOHANG) > 0) + break; + if (config_timeout > 2) { + /* Non-killable processes are indicative of file system + * problems. The process will remain as a zombie, but + * slurmd/salloc/moab will not otherwise be effected. */ + error("Failed to kill program loading user environment"); + break; + } + } + if (!found) { error("Failed to load current user environment variables"); xfree(buffer); -- GitLab