From cc0a908bc5d5046bcb2909fc98765038f15e918d Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 2 Nov 2011 15:28:05 +0530 Subject: libglusterfs: fork'ed children should start with an empty signal mask. Fork'ing causes child to inherit the signal mask of the parent. Hence executables invoked from glusterd will inherit glusterd's signal mask. Thus, utilities like gsyncd will have some signals (SIG{USR1,USR2,..}) masked, which are needed for gsyncd log-rotate command to function properly. Change-Id: Id66d185c8497cd8947f32769fa7ea62dc34e1100 BUG: 2787 Reviewed-on: http://review.gluster.com/657 Tested-by: Gluster Build System Reviewed-by: Csaba Henk Reviewed-by: Vijay Bellur --- libglusterfs/src/common-utils.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 89c000bcfb6..dee6b359232 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -1534,6 +1534,7 @@ gf_system (const char *command) char *arg = NULL; char *tmp = NULL; char *argv[100] = { NULL, }; + sigset_t set; dupcmd = gf_strdup (command); if (!dupcmd) @@ -1557,7 +1558,20 @@ gf_system (const char *command) for (idx = 3; idx < 65536; idx++) { close (idx); } - /* Step 2: execv (); */ + + /* Step 2: Start with an empty signal mask */ + ret = sigemptyset (&set); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to empty signal set"); + goto step3; + } + + ret = sigprocmask (SIG_SETMASK, &set, NULL); + if (ret) + gf_log ("", GF_LOG_ERROR, "Failed to set signal mask"); + + step3: + /* Step 3: execv (); */ ret = execvp (argv[0], argv); /* Code will not come here at all */ -- cgit