diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-17 23:14:37 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-20 17:37:44 +0300 |
commit | 41f958c4cf68541a48b20ceb608afe2308a6e6a7 (patch) | |
tree | c4e92865e98b7a3b911d355525e984151b44da22 /libbutl/process.mxx | |
parent | c00321b94d6b952d59257b4a7373a1199e874d98 (diff) |
Add timed_wait() and kill() to process class, change try_wait() signature
Review
Backup
Diffstat (limited to 'libbutl/process.mxx')
-rw-r--r-- | libbutl/process.mxx | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/libbutl/process.mxx b/libbutl/process.mxx index 0894515..a536fe9 100644 --- a/libbutl/process.mxx +++ b/libbutl/process.mxx @@ -15,6 +15,7 @@ #ifndef __cpp_lib_modules #include <string> #include <vector> +#include <chrono> #include <ostream> #include <cstddef> // size_t #include <cstdint> // uint32_t @@ -337,14 +338,32 @@ LIBBUTL_MODEXPORT namespace butl bool wait (bool ignore_errors = false); - // Return true if the process has already terminated in which case - // optionally set the argument to the result of wait(). + // Return the same result as wait() if the process has already terminated + // and nullopt otherwise. // - bool + optional<bool> try_wait (); - bool - try_wait (bool&); + // Wait for the process to terminate for up to the specified time + // duration. Return the same result as wait() if the process has + // terminated in this timeframe and nullopt otherwise. + // + // Note: not yet implemented on Windows. + // + template <typename R, typename P> + optional<bool> + timed_wait (const std::chrono::duration<R, P>&); + + // Terminate the process. + // + // On POSIX send SIGKILL to the process and wait until it terminates. The + // process exit information is available after the call returns. Noop for + // an already terminated process. + // + // Note: not yet implemented on Windows. + // + void + kill (); // Note that the destructor will wait for the process but will ignore // any errors and the exit status. |