X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmisc.cpp;h=2409e05a650a7fb5c67885d799f9359ad550037b;hb=a63fc8c311155582a1efb3bc07f010cf159f299c;hp=cf97c5506db3526535cfdbbfe3e3a9390224e8e6;hpb=2edc25f87590bd81808792c3c38cab5ae8b94eb3;p=builder.git diff --git a/source/misc.cpp b/source/misc.cpp index cf97c55..2409e05 100644 --- a/source/misc.cpp +++ b/source/misc.cpp @@ -15,7 +15,7 @@ Distributed under the LGPL using namespace std; using namespace Msp; -string run_command(const StringList &argv) +string run_command(const StringList &argv, int *status) { int pfd[2]; pipe(pfd); @@ -53,8 +53,18 @@ string run_command(const StringList &argv) int len=read(pfd[0], buf, sizeof(buf)); if(len<=0) { - if(waitpid(pid, 0, WNOHANG)) + int s; + if(waitpid(pid, &s, WNOHANG)) + { + if(status) + { + if(WIFEXITED(s)) + *status=WEXITSTATUS(s); + else + *status=-1; + } break; + } } else result.append(buf, len);