Skip to content

Conversation

rwstauner
Copy link

Summary

This PR fixes documentation issues in the Open3 module:

  1. Clarifies ignored redirection options: Each method that sets up pipes now clearly documents which redirection options will be ignored
  2. Fixes blocking behavior documentation: The popen methods (popen3, popen2, popen2e) incorrectly stated they always wait for child processes. They actually only wait when used with a block
  3. Improves pipeline examples: Removed misleading manual thread joining in block examples since the block form automatically waits

🤖 Generated with Claude Code

lib/open3.rb Outdated
# in the call to Process.spawn;
# see {Execution Options}[https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options].
#
# Note: The redirection options :in and [:out, :err] will be ignored
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: :in and [:out, :err] is it meant to be different from how the other methods are documented?

Copy link
Author

Choose a reason for hiding this comment

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

I thought that was a little weird, too.
It must be because [:out, :err] is actually what's used in the code of that method:
https://github.com/ruby/open3/pull/24/files#diff-22509663fa03dbb4fc6fa062734ed1eed523f8d125e604da6e303d8102036bceR535-R539
So if you specified that key exactly, it will be silently ignored, which was the theme of these updates.

I just tested what happens if you pass :err (or :out) specifically, then you get an error that the FD was specified twice.
We probably don't need to document that [:out, :err] is specifically silently ignored because that seems like an implementation detail that could be changed.
Maybe instead we should change the language to say something more like "just don't specify any of the redirection handles"?

I suppose we could also change the code to warn about them being passed (and ignored) (so that it isn't silent)?

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since changing the behaviour (even improving it) is a longer step, I'd settle for documentation that guided towards the current right thing to do, even if that is a little detailed.

Copy link
Author

Choose a reason for hiding this comment

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

I made the message more general, what do you think about this?

@rwstauner rwstauner force-pushed the docs branch 2 times, most recently from 122ca07 to 06a57e3 Compare July 3, 2025 15:46
1. Fixed incorrect documentation in popen3, popen2, and popen2e that
   claimed these methods always wait for child processes to exit.
   Actually, they only wait when used with a block. Without a block,
   they return immediately and the caller must wait manually.

2. Updated pipeline method examples to clarify that when used with
   a block, the methods automatically wait for all processes to exit.
   Removed misleading code that showed manual thread joining in the
   block form.
Each Open3 method that sets up pipes now documents which redirection
options will be ignored. This clarifies that when methods create pipes
for stdin, stdout, or stderr, the corresponding redirection options
in the execution options hash will have no effect.
Replace specific implementation details about which redirection options
are ignored with a more general user-friendly message. This avoids
exposing internal implementation details and provides clearer guidance
to users.
@rwstauner
Copy link
Author

rwstauner commented Sep 19, 2025

I forgot this was still open. Any other feedback about the changes?

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

Successfully merging this pull request may close these issues.

2 participants