From 19fd9a371fff4ece2c617f1e7194ffcee039f21e Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Thu, 21 Apr 2016 14:38:16 +0530 Subject: runner: extract and return actual exit status of child Intro: pid_t waitpid(pid_t pid, int *status, int options); The waitpid() system call suspends execution of the calling process until a child specified by pid argument has changed state. Here the ret (pid) value is not equal to the exit status of the child process. Check manpages for more info on this. Problem: In the current runner framework we always return the pid i.e ret value of the waitpid, as said above 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() Change-Id: Iffae99a43e540af66917b3745f21ea3c2a5a3c2d BUG: 1329129 Signed-off-by: Prasanna Kumar Kalever Reviewed-on: http://review.gluster.org/14042 Tested-by: Prasanna Kumar Kalever Reviewed-by: Kaleb KEITHLEY CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Smoke: Gluster Build System Reviewed-by: Jeff Darcy --- libglusterfs/src/run.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libglusterfs/src/run.c') diff --git a/libglusterfs/src/run.c b/libglusterfs/src/run.c index cb709546637..70ebcc54fb6 100644 --- a/libglusterfs/src/run.c +++ b/libglusterfs/src/run.c @@ -343,8 +343,13 @@ runner_end_reuse (runner_t *runner) int chstat = 0; if (runner->chpid > 0) { - if (waitpid (runner->chpid, &chstat, 0) == runner->chpid) - ret = chstat; + if (waitpid (runner->chpid, &chstat, 0) == runner->chpid) { + if (WIFEXITED(chstat)) { + ret = -WEXITSTATUS(chstat); + } else { + ret = chstat; + } + } } for (i = 0; i < 3; i++) { -- cgit