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
f7221c3a
Kaydet (Commit)
f7221c3a
authored
Şub 25, 2000
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Test case for fork1() behavior.
Only the main thread should survive in the child after a fork().
üst
4985e409
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
test_fork1
Lib/test/output/test_fork1
+1
-0
test_fork1.py
Lib/test/test_fork1.py
+54
-0
No files found.
Lib/test/output/test_fork1
0 → 100644
Dosyayı görüntüle @
f7221c3a
test_fork1
Lib/test/test_fork1.py
0 → 100644
Dosyayı görüntüle @
f7221c3a
"""This test checks for correct fork() behavior.
We want fork1() semantics -- only the forking thread survives in the
child after a fork().
On some systems (e.g. Solaris without posix threads) we find that all
active threads survive in the child after a fork(); this is an error.
"""
import
os
,
sys
,
time
,
thread
LONGSLEEP
=
2
SHORTSLEEP
=
0.5
alive
=
{}
def
f
(
id
):
while
1
:
alive
[
id
]
=
os
.
getpid
()
try
:
time
.
sleep
(
SHORTSLEEP
)
except
IOError
:
pass
def
main
():
for
i
in
range
(
4
):
thread
.
start_new
(
f
,
(
i
,))
time
.
sleep
(
LONGSLEEP
)
a
=
alive
.
keys
()
a
.
sort
()
assert
a
==
range
(
4
)
cpid
=
os
.
fork
()
if
cpid
==
0
:
# Child
time
.
sleep
(
LONGSLEEP
)
n
=
0
pid
=
os
.
getpid
()
for
key
in
alive
.
keys
():
if
alive
[
key
]
==
pid
:
n
=
n
+
1
os
.
_exit
(
n
)
else
:
# Parent
spid
,
status
=
os
.
waitpid
(
cpid
,
0
)
assert
spid
==
cpid
assert
status
==
0
,
"cause =
%
d, exit =
%
d"
%
(
status
&
0xff
,
status
>>
8
)
main
()
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