Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7ea3e295
Commit
7ea3e295
authored
Jan 03, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Un-complicate some code
parent
330453f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
15 deletions
+5
-15
Lib/subprocess.py
Lib/subprocess.py
+5
-15
No files found.
Lib/subprocess.py
View file @
7ea3e295
...
...
@@ -1092,15 +1092,9 @@ class Popen(object):
errread
,
errwrite
)
def
_close_fds
(
self
,
but
):
os
.
closerange
(
3
,
but
)
os
.
closerange
(
but
+
1
,
MAXFD
)
def
_close_all_but_a_sorted_few_fds
(
self
,
fds_to_keep
):
# precondition: fds_to_keep must be sorted and unique
def
_close_fds
(
self
,
fds_to_keep
):
start_fd
=
3
for
fd
in
fds_to_keep
:
for
fd
in
sorted
(
fds_to_keep
)
:
if
fd
>=
start_fd
:
os
.
closerange
(
start_fd
,
fd
)
start_fd
=
fd
+
1
...
...
@@ -1216,13 +1210,9 @@ class Popen(object):
# Close all other fds, if asked for
if
close_fds
:
if
pass_fds
:
fds_to_keep
=
set
(
pass_fds
)
fds_to_keep
.
add
(
errpipe_write
)
self
.
_close_all_but_a_sorted_few_fds
(
sorted
(
fds_to_keep
))
else
:
self
.
_close_fds
(
but
=
errpipe_write
)
fds_to_keep
=
set
(
pass_fds
)
fds_to_keep
.
add
(
errpipe_write
)
self
.
_close_fds
(
fds_to_keep
)
if
cwd
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment