diff options
| author | Csaba Henk <csaba@gluster.com> | 2010-09-21 09:12:31 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-21 10:41:18 -0700 | 
| commit | 78a09306fe1bd955616b8dd56e85f3af954c96b0 (patch) | |
| tree | ba24112eac9b3507ecdb4996ae32b39aa28d1735 | |
| parent | eb8561e302bd83305fb093eb8cca42b4f9f62b22 (diff) | |
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 <csaba@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1665 (glusterd hangs if spawning a child is failed)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1665
| -rw-r--r-- | libglusterfs/src/common-utils.c | 7 | 
1 files changed, 6 insertions, 1 deletions
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)  | 
