From 066d3d8cd1aa0da592e91c1d38e684e931acd1af Mon Sep 17 00:00:00 2001 From: Tanguy Date: Thu, 19 May 2022 11:25:34 +0200 Subject: [PATCH] asyncproc: Expose close closes #16 --- asynctools/asyncproc.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/asynctools/asyncproc.nim b/asynctools/asyncproc.nim index 42cff1b..0bcc14e 100644 --- a/asynctools/asyncproc.nim +++ b/asynctools/asyncproc.nim @@ -204,6 +204,9 @@ proc kill*(p: AsyncProcess) ## Kill the process ``p``. On Posix OSes the procedure sends ``SIGKILL`` to ## the process. On Windows ``kill()`` is simply an alias for ``terminate()``. +proc close*(p: AsyncProcess) + ## When the process has finished executing, cleanup related handles. + proc running*(p: AsyncProcess): bool ## Returns `true` if the process ``p`` is still running. Returns immediately. @@ -264,7 +267,7 @@ when defined(windows): inc(L, x.len+1) (str, L) - proc close(p: AsyncProcess) = + proc close*(p: AsyncProcess) = if p.inPipe != nil: close(p.inPipe) if p.outPipe != nil: close(p.outPipe) if p.errPipe != nil: close(p.errPipe) @@ -782,7 +785,7 @@ else: startProcessFail(data) {.pop} - proc close(p: AsyncProcess) = + proc close*(p: AsyncProcess) = ## We need to `wait` for process, to avoid `zombie`, so if `running()` ## returns `false`, then process exited and `wait()` was called. doAssert(not p.running())