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

Enhance simple_command to close stdin to avoid this class of bugs in the future. #4187

Closed
xiangce opened this issue Aug 9, 2024 · 2 comments · Fixed by #4189
Closed

Enhance simple_command to close stdin to avoid this class of bugs in the future. #4187

xiangce opened this issue Aug 9, 2024 · 2 comments · Fixed by #4189

Comments

@xiangce
Copy link
Contributor

xiangce commented Aug 9, 2024

          I'd suggest to enhance `simple_command` to close stdin to avoid this class of bugs in the future.

Originally posted by @ekohl in #4186 (review)

For more details see:

@ShimShtein
Copy link

I think closing the stdin can also influence the caller process, which is undesirable.

Maybe the simple_command should use the equivalent of ruby's popen3:

Creates streams stdin, stdout, and stderr, which are the standard input, standard output, and standard error streams in the child process.

This way the child process would be completely isolated from the caller.

@ekohl
Copy link

ekohl commented Aug 11, 2024

The module already extensively uses subprocess which you can easily pass stdin=subprocess.DEVNULL to achieve that.

xiangce added a commit that referenced this issue Aug 13, 2024
- For the first cmd to run in subprocess.call, specified
  "stdin=subprocess.DEVNULL" to avoid it from eating
  the stdin behind it
- fix: #4187

Signed-off-by: Xiangce Liu <[email protected]>
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 a pull request may close this issue.

3 participants