]> git.tdb.fi Git - builder.git/blobdiff - source/misc.cpp
Use mspio for all I/O operations
[builder.git] / source / misc.cpp
index 4d2019a5fd28c2a1954884f8683fdb4a691b5292..cf97c5506db3526535cfdbbfe3e3a9390224e8e6 100644 (file)
@@ -5,11 +5,11 @@ Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <iostream>
 #include <sys/wait.h>
 #include <fcntl.h>
 #include <cstdlib>
 #include <cstring>
+#include <msp/io/print.h>
 #include "misc.h"
 
 using namespace std;
@@ -43,7 +43,7 @@ string run_command(const StringList &argv)
                ::exit(1);
        }
        else if(pid==-1)
-               cerr<<"Failed to execute "<<argv.front()<<'\n';
+               IO::print(IO::cerr, "Failed to execute %s\n", argv.front());
        else
        {
                close(pfd[1]);
@@ -59,6 +59,7 @@ string run_command(const StringList &argv)
                        else
                                result.append(buf, len);
                }
+               close(pfd[0]);
        }
 
        return result;