summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2016-04-29 18:28:20 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-05-01 20:54:37 -0700
commitd6b406b84dd840d15472b203052f7679d96dc321 (patch)
treea93e47cb6f314b9b018d03d15acd619f56e551a9 /libglusterfs/src
parentdc6178714cd84d3de894d0972c20950b59d30017 (diff)
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() Backport of: > Change-Id: Iffae99a43e540af66917b3745f21ea3c2a5a3c2d > BUG: 1329129 > Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> > Reviewed-on: http://review.gluster.org/14042 > Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com> > Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> > CentOS-regression: Gluster Build System <jenkins@build.gluster.com> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Smoke: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Change-Id: I137b2fc120ec2b1137bf8a4e6b180f1787bf5908 BUG: 1331759 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Reviewed-on: http://review.gluster.org/14116 Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/run.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libglusterfs/src/run.c b/libglusterfs/src/run.c
index 6018a58ad5f..7c237b35fa0 100644
--- a/libglusterfs/src/run.c
+++ b/libglusterfs/src/run.c
@@ -342,8 +342,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++) {