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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// file : libbutl/process-run.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#ifndef __cpp_modules
#include <libbutl/process.mxx>
#endif
// C includes.
#ifndef __cpp_lib_modules
#include <cstdlib> // exit()
#include <iostream> // cerr
#endif
// Other includes.
#ifdef __cpp_modules
module butl.process;
// Only imports additional to interface.
#ifdef __clang__
#ifdef __cpp_lib_modules
import std.core;
import std.io;
#endif
import butl.path;
#endif
import butl.utility; // operator<<(ostream,exception)
#else
#include <libbutl/utility.mxx>
#endif
using namespace std;
namespace butl
{
process
process_start (const dir_path* cwd,
const process_path& pp,
const char* cmd[],
const char* const* envvars,
process::pipe in,
process::pipe out,
process::pipe err)
{
try
{
return process (pp, cmd,
in, out, err,
cwd != nullptr ? cwd->string ().c_str () : nullptr,
envvars);
}
catch (const process_child_error& e)
{
cerr << "unable to execute " << cmd[0] << ": " << e << endl;
exit (1);
}
}
}
|