aboutsummaryrefslogtreecommitdiff
path: root/butl/process-run.cxx
blob: c3b2856a48bba57b5f11aaec555b7b6b30277e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// file      : butl/process-run.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <butl/process>

#include <cstdlib>  // exit()
#include <iostream> // cerr

using namespace std;

namespace butl
{
  process
  process_start (const dir_path& cwd,
                 const process_path& pp,
                 const char* cmd[],
                 int in,
                 int out,
                 int err)
  {
    try
    {
      return process (cwd.string ().c_str (), pp, cmd, in, out, err);
    }
    catch (const process_child_error& e)
    {
      cerr << "unable to execute " << cmd[0] << ": " << e << endl;
      exit (1);
    }
  }
}