summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenky Shankar <venky@gluster.com>2011-11-02 15:28:05 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-04 02:06:25 -0700
commitcc0a908bc5d5046bcb2909fc98765038f15e918d (patch)
treef41a7d552c6905a94098582587f735afb029a4de
parentbd42aec6c907c14f7c86d7fd6f60b8d78d411fb1 (diff)
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 <jenkins@build.gluster.com> Reviewed-by: Csaba Henk <csaba@gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--libglusterfs/src/common-utils.c16
1 files changed, 15 insertions, 1 deletions
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 */