]> git.tdb.fi Git - builder.git/commitdiff
Remove the now-obsolete run_command function
authorMikko Rasa <tdb@tdb.fi>
Wed, 30 May 2012 19:31:44 +0000 (19:31 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 8 Jul 2012 21:08:52 +0000 (00:08 +0300)
source/misc.cpp [deleted file]
source/misc.h

diff --git a/source/misc.cpp b/source/misc.cpp
deleted file mode 100644 (file)
index c85f840..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <cstdlib>
-#include <cstring>
-#include <unistd.h>
-#include <msp/io/print.h>
-#include "misc.h"
-
-using namespace std;
-using namespace Msp;
-
-string run_command(const StringList &argv, int *status)
-{
-       int pfd[2];
-       pipe(pfd);
-
-       string result;
-
-       pid_t pid = fork();
-       if(pid==0)
-       {
-               char *argv_[argv.size()+1];
-
-               unsigned j = 0;
-               for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
-                       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);
-               dup2(devnull, 2);
-               close(devnull);
-
-               execvp(argv_[0], argv_);
-               ::exit(1);
-       }
-       else if(pid==-1)
-               IO::print(IO::cerr, "Failed to execute %s\n", argv.front());
-       else
-       {
-               close(pfd[1]);
-               while(1)
-               {
-                       char buf[1024];
-                       int len = read(pfd[0], buf, sizeof(buf));
-                       if(len<=0)
-                       {
-                               int s;
-                               if(waitpid(pid, &s, WNOHANG))
-                               {
-                                       if(status)
-                                       {
-                                               if(WIFEXITED(s))
-                                                       *status = WEXITSTATUS(s);
-                                               else
-                                                       *status = -1;
-                                       }
-                                       break;
-                               }
-                       }
-                       else
-                               result.append(buf, len);
-               }
-               close(pfd[0]);
-       }
-
-       return result;
-}
-
-
index 0d6997c53263b02c3dacce41763641ead1a6abab..e3d4be849e12c139d18d90e909859d5fc51b5cd5 100644 (file)
@@ -17,8 +17,4 @@ typedef std::list<std::string> StringList;
 typedef std::list<Msp::FS::Path> PathList;
 typedef std::map<std::string, std::string> StringMap;
 
-/** Runs a command and returns its output as a string.  The exit status of the
-command is returned in the second parameter if it is not null. */
-std::string run_command(const StringList &, int * =0);
-
 #endif