aboutsummaryrefslogtreecommitdiff
path: root/libbutl/process.mxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-10-08 21:24:00 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-11-05 18:23:39 +0300
commite197ae6fae73719266fd4747f499cd6106fbff4e (patch)
tree3cf4e18310469492f371045ae83c28cb25fab4e7 /libbutl/process.mxx
parent7a8386289b18678c2ee49ffdfcf71e3a2abd3258 (diff)
Add process::term() and implement process::kill() on Windows
Diffstat (limited to 'libbutl/process.mxx')
-rw-r--r--libbutl/process.mxx30
1 files changed, 20 insertions, 10 deletions
diff --git a/libbutl/process.mxx b/libbutl/process.mxx
index 54abdec..9106549 100644
--- a/libbutl/process.mxx
+++ b/libbutl/process.mxx
@@ -360,27 +360,37 @@ LIBBUTL_MODEXPORT namespace butl
// 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.
+ // Note that the destructor will wait for the process but will ignore
+ // any errors and the exit status.
+ //
+ ~process () {if (handle != 0) wait (true);}
+
+ // Process termination.
//
- // 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.
+
+ // Send SIGKILL to the process on POSIX and call TerminateProcess() with
+ // DBG_TERMINATE_PROCESS exit code on Windows. Noop for an already
+ // terminated process.
+ //
+ // Note that if the process is killed, it terminates as if it has called
+ // abort() (functions registered with atexit() are not called, etc).
//
- // Note: not yet implemented on Windows.
+ // Also note that on Windows calling this function for a terminating
+ // process results in the EPERM process_error exception.
//
void
kill ();
- // Note that the destructor will wait for the process but will ignore
- // any errors and the exit status.
+ // Send SIGTERM to the process on POSIX and call kill() on Windows (where
+ // there is no general way to terminate a console process gracefully).
+ // Noop for an already terminated process.
//
- ~process () {if (handle != 0) wait (true);}
+ void
+ term ();
// Moveable-only type.
//