Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncproc: Expose close #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions asynctools/asyncproc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -264,7 +267,7 @@ when defined(windows):
inc(L, x.len+1)
(str, L)

proc close(p: AsyncProcess) =
proc close*(p: AsyncProcess) =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to export this procedure. Just the top level one.

if p.inPipe != nil: close(p.inPipe)
if p.outPipe != nil: close(p.outPipe)
if p.errPipe != nil: close(p.errPipe)
Expand Down Expand Up @@ -782,7 +785,7 @@ else:
startProcessFail(data)
{.pop}

proc close(p: AsyncProcess) =
proc close*(p: AsyncProcess) =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

## 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())
Expand Down