diff options
Diffstat (limited to 'butl')
-rw-r--r-- | butl/process | 3 | ||||
-rw-r--r-- | butl/process-run.txx | 4 | ||||
-rw-r--r-- | butl/process.cxx | 11 | ||||
-rw-r--r-- | butl/process.ixx | 8 |
4 files changed, 24 insertions, 2 deletions
diff --git a/butl/process b/butl/process index 6f22718..c138edc 100644 --- a/butl/process +++ b/butl/process @@ -347,6 +347,9 @@ namespace butl print (std::ostream&, const char* const args[], size_t n = 0); public: + id_type + id () const; + static id_type current_id (); diff --git a/butl/process-run.txx b/butl/process-run.txx index 013be4c..8368890 100644 --- a/butl/process-run.txx +++ b/butl/process-run.txx @@ -20,7 +20,7 @@ namespace butl inline int process_stderr (const auto_fd& v) {assert (v.get () >= 0); return v.get ();} - process + LIBBUTL_EXPORT process process_start (const dir_path& cwd, const process_path& pp, const char* cmd[], @@ -55,7 +55,7 @@ namespace butl // const std::size_t args_size (sizeof... (args)); - std::string storage[args_size]; + std::string storage[args_size != 0 ? args_size : 1]; const char* cmd[args_size + 2] = { pp.recall_string (), process_arg_as (args, storage[index])..., diff --git a/butl/process.cxx b/butl/process.cxx index 74892e6..05c06f1 100644 --- a/butl/process.cxx +++ b/butl/process.cxx @@ -1121,6 +1121,17 @@ namespace butl } process::id_type process:: + id () const + { + id_type r (GetProcessId (handle)); + + if (r == 0) + throw process_error (last_error_msg ()); + + return r; + } + + process::id_type process:: current_id () { return GetCurrentProcessId (); diff --git a/butl/process.ixx b/butl/process.ixx index c452b0f..65aeeb6 100644 --- a/butl/process.ixx +++ b/butl/process.ixx @@ -49,6 +49,14 @@ namespace butl return *this; } +#ifndef _WIN32 + inline process::id_type process:: + id () const + { + return handle; + } +#endif + inline const char* process_path:: recall_string () const { |