Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c20a7b97
Kaydet (Commit)
c20a7b97
authored
Agu 25, 2013
tarafından
Charles-François Natali
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge.
üst
b33baf1c
249cdc39
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
11 deletions
+29
-11
test_subprocess.py
Lib/test/test_subprocess.py
+17
-0
_posixsubprocess.c
Modules/_posixsubprocess.c
+12
-11
No files found.
Lib/test/test_subprocess.py
Dosyayı görüntüle @
c20a7b97
...
...
@@ -1938,6 +1938,23 @@ class POSIXProcessTestCase(BaseTestCase):
self
.
assertRaises
(
OSError
,
os
.
waitpid
,
pid
,
0
)
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
def
test_close_fds_after_preexec
(
self
):
fd_status
=
support
.
findfile
(
"fd_status.py"
,
subdir
=
"subprocessdata"
)
# this FD is used as dup2() target by preexec_fn, and should be closed
# in the child process
fd
=
os
.
dup
(
1
)
self
.
addCleanup
(
os
.
close
,
fd
)
p
=
subprocess
.
Popen
([
sys
.
executable
,
fd_status
],
stdout
=
subprocess
.
PIPE
,
close_fds
=
True
,
preexec_fn
=
lambda
:
os
.
dup2
(
1
,
fd
))
output
,
ignored
=
p
.
communicate
()
remaining_fds
=
set
(
map
(
int
,
output
.
split
(
b
','
)))
self
.
assertNotIn
(
fd
,
remaining_fds
)
@unittest.skipUnless
(
mswindows
,
"Windows specific tests"
)
class
Win32ProcessTestCase
(
BaseTestCase
):
...
...
Modules/_posixsubprocess.c
Dosyayı görüntüle @
c20a7b97
...
...
@@ -412,17 +412,6 @@ child_exec(char *const exec_array[],
POSIX_CALL
(
close
(
errwrite
));
}
if
(
close_fds
)
{
int
local_max_fd
=
max_fd
;
#if defined(__NetBSD__)
local_max_fd
=
fcntl
(
0
,
F_MAXFD
);
if
(
local_max_fd
<
0
)
local_max_fd
=
max_fd
;
#endif
/* TODO HP-UX could use pstat_getproc() if anyone cares about it. */
_close_open_fd_range
(
3
,
local_max_fd
,
py_fds_to_keep
);
}
if
(
cwd
)
POSIX_CALL
(
chdir
(
cwd
));
...
...
@@ -451,6 +440,18 @@ child_exec(char *const exec_array[],
/* Py_DECREF(result); - We're about to exec so why bother? */
}
/* close FDs after executing preexec_fn, which might open FDs */
if
(
close_fds
)
{
int
local_max_fd
=
max_fd
;
#if defined(__NetBSD__)
local_max_fd
=
fcntl
(
0
,
F_MAXFD
);
if
(
local_max_fd
<
0
)
local_max_fd
=
max_fd
;
#endif
/* TODO HP-UX could use pstat_getproc() if anyone cares about it. */
_close_open_fd_range
(
3
,
local_max_fd
,
py_fds_to_keep
);
}
/* This loop matches the Lib/os.py _execvpe()'s PATH search when */
/* given the executable_list generated by Lib/subprocess.py. */
saved_errno
=
0
;
...
...
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