| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1390,6 +1390,10 @@ def _get_handles(self, stdin, stdout, stderr): | |
| errread, errwrite) | ||
|
|
||
|
|
||
| def _posix_spawn(self, args, executable): | ||
| """Execute program using os.posix_spawn().""" | ||
| self.pid = os.posix_spawn(executable, args, os.environ) | ||
|
|
||
| def _execute_child(self, args, executable, preexec_fn, close_fds, | ||
| pass_fds, cwd, env, | ||
| startupinfo, creationflags, shell, | ||
| Expand All | @@ -1414,6 +1418,21 @@ def _execute_child(self, args, executable, preexec_fn, close_fds, | |
|
|
||
| if executable is None: | ||
| executable = args[0] | ||
|
|
||
| if (os.path.dirname(executable) | ||
| and preexec_fn is None | ||
| and not close_fds | ||
| and not pass_fds | ||
| and cwd is None | ||
| and env is None | ||
| and p2cread == p2cwrite == -1 | ||
| and c2pread == c2pwrite == -1 | ||
| and errread == errwrite == -1 | ||
| and not restore_signals | ||
| and not start_new_session): | ||
| self._posix_spawn(args, executable) | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityChecking self.std* is still not enough. Those fields are for the parent's ends of pipes, but if a caller redirects to a descriptor, there is no such end. For example, subprocess.call(['/bin/sleep', '1000'], stdout=fd, close_fds=False, restore_signals=False) doesn't work properly.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@izbyshev: Oh right! I fixed the test: test (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) instead of (self.stdin, self.stdout, self.stderr). Is it better now?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes, LGTM now. There is another potential problem with posix_spawn: asynchronous error notification. _posixsubprocess uses a pipe to notify the parent about all errors up to and including execve errors, so its style is synchronous. Glibc and musl use the pipe-based notification too, but they are not required to do that, and I don't know what other implementations do.
Sorry, something went wrong.
All reactions
|
||
| return | ||
|
|
||
| orig_executable = executable | ||
|
|
||
| # For transferring possible exec failure from child to parent. | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| subprocess.Popen can now use posix_spawn() in some cases. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.