summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-01-22 11:18:18 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2016-01-22 11:18:18 +0100
commited93a5f30bc5be7daed1738812e090707a319090 (patch)
tree55807674ce2d901e480a6276931cf560573babbe
parentcabc5f0993e89732295c5a23f252cdecaa1a1aed (diff)
launch: fix error when pipe is broken
Change-Id: I41d0125dbbd8552f044add81b345a04a0f4fe8ac Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afm-launch.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/afm-launch.c b/src/afm-launch.c
index 1f9907d..bdd5ab1 100644
--- a/src/afm-launch.c
+++ b/src/afm-launch.c
@@ -284,13 +284,12 @@ static int launchexec2(struct afm_launch_desc *desc, pid_t children[2], struct l
close(spipe[0]);
/* wait the ready signal (that transmit the slave pid) */
rc = read(mpipe[0], &children[1], sizeof children[1]);
- if (rc < 0) {
+ close(mpipe[0]);
+ if (rc <= 0) {
ERROR("reading master pipe failed: %m");
- close(mpipe[0]);
close(spipe[1]);
return -1;
}
- close(mpipe[0]);
assert(rc == sizeof children[1]);
/* start the child */
rc = write(spipe[1], "start", 5);
@@ -344,7 +343,7 @@ static int launchexec2(struct afm_launch_desc *desc, pid_t children[2], struct l
/********* in the slave child ************/
close(mpipe[0]);
rc = read(spipe[0], message, sizeof message);
- if (rc < 0) {
+ if (rc <= 0) {
ERROR("reading slave pipe failed: %m");
_exit(1);
}
@@ -368,7 +367,7 @@ static int launchexec2(struct afm_launch_desc *desc, pid_t children[2], struct l
}
else {
rc = write(mpipe[1], &children[1], sizeof children[1]);
- if (rc < 0) {
+ if (rc <= 0) {
ERROR("can't write master pipe: %m");
}
else {