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
bd7b5dd8
Commit
bd7b5dd8
authored
Jun 04, 2012
by
Richard Oudkerk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent handle leak if CreateProcess() fails in multiprocessing
parent
86eb7e97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
25 deletions
+27
-25
Lib/multiprocessing/forking.py
Lib/multiprocessing/forking.py
+27
-25
No files found.
Lib/multiprocessing/forking.py
View file @
bd7b5dd8
...
@@ -209,6 +209,9 @@ else:
...
@@ -209,6 +209,9 @@ else:
_tls
=
_thread
.
_local
()
_tls
=
_thread
.
_local
()
def
__init__
(
self
,
process_obj
):
def
__init__
(
self
,
process_obj
):
cmd
=
' '
.
join
(
'"%s"'
%
x
for
x
in
get_command_line
())
prep_data
=
get_preparation_data
(
process_obj
.
_name
)
# create pipe for communication with child
# create pipe for communication with child
rfd
,
wfd
=
os
.
pipe
()
rfd
,
wfd
=
os
.
pipe
()
...
@@ -216,31 +219,30 @@ else:
...
@@ -216,31 +219,30 @@ else:
rhandle
=
duplicate
(
msvcrt
.
get_osfhandle
(
rfd
),
inheritable
=
True
)
rhandle
=
duplicate
(
msvcrt
.
get_osfhandle
(
rfd
),
inheritable
=
True
)
os
.
close
(
rfd
)
os
.
close
(
rfd
)
# start process
with
open
(
wfd
,
'wb'
,
closefd
=
True
)
as
to_child
:
cmd
=
get_command_line
()
+
[
rhandle
]
# start process
cmd
=
' '
.
join
(
'"%s"'
%
x
for
x
in
cmd
)
try
:
hp
,
ht
,
pid
,
tid
=
_winapi
.
CreateProcess
(
hp
,
ht
,
pid
,
tid
=
_winapi
.
CreateProcess
(
_python_exe
,
cmd
,
None
,
None
,
1
,
0
,
None
,
None
,
None
_python_exe
,
cmd
+
(
' %s'
%
rhandle
),
)
None
,
None
,
1
,
0
,
None
,
None
,
None
_winapi
.
CloseHandle
(
ht
)
)
close
(
rhandle
)
_winapi
.
CloseHandle
(
ht
)
finally
:
# set attributes of self
close
(
rhandle
)
self
.
pid
=
pid
self
.
returncode
=
None
# set attributes of self
self
.
_handle
=
hp
self
.
pid
=
pid
self
.
sentinel
=
int
(
hp
)
self
.
returncode
=
None
self
.
_handle
=
hp
# send information to child
self
.
sentinel
=
int
(
hp
)
prep_data
=
get_preparation_data
(
process_obj
.
_name
)
to_child
=
os
.
fdopen
(
wfd
,
'wb'
)
# send information to child
Popen
.
_tls
.
process_handle
=
int
(
hp
)
Popen
.
_tls
.
process_handle
=
int
(
hp
)
try
:
try
:
dump
(
prep_data
,
to_child
,
HIGHEST_PROTOCOL
)
dump
(
prep_data
,
to_child
,
HIGHEST_PROTOCOL
)
dump
(
process_obj
,
to_child
,
HIGHEST_PROTOCOL
)
dump
(
process_obj
,
to_child
,
HIGHEST_PROTOCOL
)
finally
:
finally
:
del
Popen
.
_tls
.
process_handle
del
Popen
.
_tls
.
process_handle
to_child
.
close
()
@
staticmethod
@
staticmethod
def
thread_is_spawning
():
def
thread_is_spawning
():
...
...
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