From 41f958c4cf68541a48b20ceb608afe2308a6e6a7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 17 Aug 2018 23:14:37 +0300 Subject: Add timed_wait() and kill() to process class, change try_wait() signature Review Backup --- libbutl/process.mxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'libbutl/process.mxx') 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 #include +#include #include #include // size_t #include // 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 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 + optional + timed_wait (const std::chrono::duration&); + + // 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. -- cgit v1.1