-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
subprocess.DEVNULL #50120
Comments
The subprocess module exposes the PIPE and STDOUT constants to be used Often, stderr needs to be redirected to /dev/null (on posix). It would Perhaps, that might be as simple as DEVNULL = os.open(os.devnull, os.OS_RDWR) and re-use the same, single file descriptor. |
Typo. That should be ..., os.O_RDWR) |
-1 on this one. |
Lucas, Windows has a /dev/null-like device. I think Jean's suggestion is |
Here is a fairly simple patch that adds the subprocess.DEVNULL constant. |
Hmm, we don't like these open-for-eternity file descriptors; we had such a thing for os.urandom() but removed it (see bpo-1177468). I'm okay with DEVNULL (or even just NULL) as a shorthand, but it should open (and close) the devnull device each time just as if a normal fd was given. |
I think if you look closely at the patch, the fd does not stay open the whole time. It is opened if necessary in _get_handles() with e.g.: elif stdin == DEVNULL: and then closed in _execute_child() with: if hasattr(self, '_devnull'):
os.close(self._devnull) which is executed from __init__(). So I don't think it stays open for eternity :-) |
Right, sorry then :) |
New changeset eaf93e156dff by Ross Lagerwall in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: