diff options
author | John Ankarstrom <john@ankarstrom.se> | 2021-07-07 20:15:39 +0200 |
---|---|---|
committer | John Ankarstrom <john@ankarstrom.se> | 2021-07-07 20:15:39 +0200 |
commit | e57e5137040e65dd82474bc4c590c8c23cfce509 (patch) | |
tree | 3e9b8ee408ae54f453ffaa0a1c5f4e17d3cfcdc4 /build.c | |
parent | 910b33f06a16362f8a41114894d977df928c18fc (diff) | |
download | build-e57e5137040e65dd82474bc4c590c8c23cfce509.tar.gz |
Check status of shell command
Diffstat (limited to 'build.c')
-rw-r--r-- | build.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -32,7 +32,7 @@ main(int argc, char *argv[]) { char *b, buf[MAXBUF], *cmd[MAXCMDS], *d, *dep, *name, *tgt; FILE *fp; - int c, dflag, fflag, i, icmd, j; + int c, dflag, fflag, i, icmd, j, s, status; struct stat sb, ssb; /* allocate memory */ @@ -46,6 +46,7 @@ main(int argc, char *argv[]) if (!dep) err(1, "malloc"); tgt[0] = dep[0] = 0; + status = 0; /* process arguments */ name = argv[0]; @@ -162,11 +163,15 @@ build: strncat(buf, cmd[j], MAXBUF-1); strncat(buf, "\n", MAXBUF-1); } - system(buf); + s = system(buf); + if (s != -1) + status += s; done: fclose(fp); } + + return status > 0; } void |