From f58fb8821d1c5d96a8f1eb83930a33a4379196e2 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Sat, 30 Apr 2016 14:59:26 +0530 Subject: glusterfsd: fix to return actual exit status on mount process Problem: Currently, we always exit mount process with the pid as the exit number which is return value of the waitpid(), it is not the exit value of the child process Solution: Extract the actual exit code/status in case if the child terminated normally, that is, by calling exit(3) or _exit(2), or by returning from main() Backport of: > Change-Id: Iefec6e27b5a5a98a22f016e49967978853662e37 > BUG: 1331042 > Signed-off-by: Prasanna Kumar Kalever > Reviewed-on: http://review.gluster.org/14094 > Tested-by: Prasanna Kumar Kalever > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Raghavendra Talur > Reviewed-by: Jeff Darcy Change-Id: Ib9fd878461b0b409c9d55d526cf60d7276c31775 BUG: 1331938 Signed-off-by: Prasanna Kumar Kalever Reviewed-on: http://review.gluster.org/14129 Tested-by: Prasanna Kumar Kalever Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Atin Mukherjee Reviewed-by: Raghavendra G --- glusterfsd/src/glusterfsd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index ef4b81c65f5..a9561224b72 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -2106,7 +2106,7 @@ daemonize (glusterfs_ctx_t *ctx) int ret = -1; cmd_args_t *cmd_args = NULL; int cstatus = 0; - int err = 0; + int err = 1; cmd_args = &ctx->cmd_args; @@ -2151,14 +2151,17 @@ daemonize (glusterfs_ctx_t *ctx) if (ctx->mnt_pid > 0) { ret = waitpid (ctx->mnt_pid, &cstatus, 0); - if (!(ret == ctx->mnt_pid && cstatus == 0)) { + if (!(ret == ctx->mnt_pid)) { + if (WIFEXITED(cstatus)) { + err = WEXITSTATUS(cstatus); + } else { + err = cstatus; + } gf_msg ("daemonize", GF_LOG_ERROR, 0, glusterfsd_msg_25); - exit (1); + exit (err); } } - - err = 1; read (ctx->daemon_pipe[0], (void *)&err, sizeof (err)); _exit (err); } -- cgit