]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/unix/process.cpp
Add move semantics to Variant
[libs/core.git] / source / core / unix / process.cpp
index 76141b0360a56de7ed150878430f4a6848a26279..ee0a36d3b783ea30383470f6c411f3a007c54bed 100644 (file)
@@ -4,6 +4,7 @@
 #include <msp/core/systemerror.h>
 #include <msp/fs/dir.h>
 #include <msp/io/console.h>
+#include "except.h"
 #include "process.h"
 #include "process_private.h"
 
@@ -12,7 +13,9 @@ using namespace std;
 namespace Msp {
 
 Process::~Process()
-{ }
+{
+       delete priv;
+}
 
 void Process::platform_get_self_info(Private &priv)
 {
@@ -35,10 +38,11 @@ void Process::execute(const string &command, bool path_search, const Arguments &
                        argv[0] = command.c_str();
                        for(unsigned i=0; i<args.size(); ++i)
                                argv[i+1] = args[i].c_str();
-                       argv[args.size()+1] = 0;
+                       argv[args.size()+1] = nullptr;
 
                        if(redirect)
                        {
+                               // dup2 clears O_CLOEXEC
                                if(cin)
                                        IO::cin.redirect(*cin);
                                if(cout)
@@ -69,7 +73,7 @@ void Process::execute(const string &command, bool path_search, const Arguments &
 bool Process::wait(bool block)
 {
        if(!running)
-               throw logic_error("not running");
+               throw invalid_state("not running");
 
        int status;
        int pid = waitpid(priv->info.pid, &status, (block ? 0 : WNOHANG));