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

Process docs make false claim about closing handles #177

Open
ceedubs opened this issue Sep 7, 2023 · 0 comments
Open

Process docs make false claim about closing handles #177

ceedubs opened this issue Sep 7, 2023 · 0 comments

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Sep 7, 2023

Both the Process docs and the Process.start docs claim that when the process finishes the handles will be closed, but that does not seem to be the case:

main = do
  (stdin, stdout, stderr, p) = start "echo" ["hello", "world"]
  exitCode = wait p
  Debug.trace "stdin is open?" (isOpen stdin)
  Debug.trace "stdout is open?" (isOpen stdout)
  Debug.trace "stderr is open?" (isOpen stderr)
  Handle.close stdin
  Debug.trace "stdin is open now?" (isOpen stdin)
  Handle.close stdout
  Debug.trace "stdout is open now?" (isOpen stdout)
  Handle.close stderr
  Debug.trace "stderr is open now?" (isOpen stderr)
> run main
trace: stdin is open?
true
trace: stdout is open?
true
trace: stderr is open?
true
trace: stdin is open now?
false
trace: stdout is open now?
false
trace: stderr is open now?
false

I think that the correct solution to this is to change the docs. You don't necessarily want the handles (or at least the stdout and stderr) handles to be closed immediately, because the caller might not be finished consuming them yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant