#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"
namespace Msp {
Process::~Process()
-{ }
+{
+ delete priv;
+}
void Process::platform_get_self_info(Private &priv)
{
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)
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));