commit 8af353ea6c8ef5c093442ecc248c03fa4c267850
parent 1198f783db53c8561ca78bb9240b749eb0a00e64
Author: Tomas Hlavaty <tom@logand.com>
Date: Thu, 12 Sep 2019 22:53:00 +0200
readability
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/osmtile.c b/osmtile.c
@@ -107,16 +107,17 @@ static int probe(char *path) {
}
static void run(char *args[]) {
- int stat;
- switch(fork()) {
- case -1: fail(1, "fork failed\n");
- case 0:
- execvp(*args, args);
- fail(1, "exec %s failed\n", *args);
- default:
+ int z = fork();
+ if(z < 0) fail(1, "fork failed\n");
+ if(z) { /* parent */
+ int stat;
wait(&stat);
if(stat) fail(1, "%s failed %d\n", *args, stat);
+ return;
}
+ /* child */
+ execvp(*args, args);
+ fail(1, "exec %s failed\n", *args);
}
static void cleanup(void) {