X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmisc.cpp;h=c85f840815ae739aaf54ed24960128691d48e9a8;hb=2ea79c8f3ca8c12907a6c121ec564f5a4d643f52;hp=2409e05a650a7fb5c67885d799f9359ad550037b;hpb=a63fc8c311155582a1efb3bc07f010cf159f299c;p=builder.git diff --git a/source/misc.cpp b/source/misc.cpp index 2409e05..c85f840 100644 --- a/source/misc.cpp +++ b/source/misc.cpp @@ -1,14 +1,8 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include #include +#include #include #include "misc.h" @@ -22,20 +16,20 @@ string run_command(const StringList &argv, int *status) string result; - pid_t pid=fork(); + pid_t pid = fork(); if(pid==0) { char *argv_[argv.size()+1]; - unsigned j=0; + unsigned j = 0; for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i) - argv_[j++]=strdup(i->c_str()); - argv_[j]=0; + argv_[j++] = strdup(i->c_str()); + argv_[j] = 0; close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]); - int devnull=open("/dev/null", O_WRONLY); + int devnull = open("/dev/null", O_WRONLY); dup2(devnull, 2); close(devnull); @@ -50,7 +44,7 @@ string run_command(const StringList &argv, int *status) while(1) { char buf[1024]; - int len=read(pfd[0], buf, sizeof(buf)); + int len = read(pfd[0], buf, sizeof(buf)); if(len<=0) { int s; @@ -59,9 +53,9 @@ string run_command(const StringList &argv, int *status) if(status) { if(WIFEXITED(s)) - *status=WEXITSTATUS(s); + *status = WEXITSTATUS(s); else - *status=-1; + *status = -1; } break; }