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);
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);