From 78a09306fe1bd955616b8dd56e85f3af954c96b0 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Tue, 21 Sep 2010 09:12:31 +0000 Subject: libglusterfs: handle failure properly in gf_system() - Child must be terminated if execve(2) fails, otherwise it will deadlock parent - Status, as of given by waitpid(2), is aggregated data, should not be returned as is. In fact, there is not much point in threading up the exitvalue: callers usually return gf_system result as is, and according to glusterfs conventions, they should return -1 on failure. Therefore now we check only for success/fail, and return 0/-1. Signed-off-by: Csaba Henk Signed-off-by: Vijay Bellur BUG: 1665 (glusterd hangs if spawning a child is failed) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1665 --- libglusterfs/src/common-utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 022fdf35537..75476a0291e 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -1510,11 +1510,16 @@ gf_system (const char *command) /* Code will not come here at all */ gf_log ("", GF_LOG_ERROR, "execv of (%s) failed", command); + + kill (getpid(), SIGKILL); } if (pid > 0) { /* Current, ie, parent process */ pid = waitpid (pid, &status, 0); - ret = status; + if (WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS) + ret = 0; + else + ret = -1; } out: if (dupcmd) -- cgit