1 """This test checks for correct fork() behavior.
3 We want fork1() semantics -- only the forking thread survives in the
6 On some systems (e.g. Solaris without posix threads) we find that all
7 active threads survive in the child after a fork(); this is an error.
9 While BeOS doesn't officially support fork and native threading in
10 the same application, the present example should work just fine. DC
13 import os
, sys
, time
, thread
14 from test
.test_support
import verify
, verbose
, TestSkipped
18 except AttributeError:
19 raise TestSkipped
, "os.fork not defined -- skipping test_fork1"
33 alive
[id] = os
.getpid()
35 time
.sleep(SHORTSLEEP
)
40 for i
in range(NUM_THREADS
):
41 thread
.start_new(f
, (i
,))
47 verify(a
== range(NUM_THREADS
))
49 prefork_lives
= alive
.copy()
51 if sys
.platform
in ['unixware7']:
60 for key
in alive
.keys():
61 if alive
[key
] != prefork_lives
[key
]:
66 spid
, status
= os
.waitpid(cpid
, 0)
69 "cause = %d, exit = %d" % (status
&0xff, status
>>8) )
73 time
.sleep(2*SHORTSLEEP
) # Wait for threads to die