"""This test checks for correct fork() behavior.
We want fork1() semantics -- only the forking thread survives in the
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.
While BeOS doesn't officially support fork and native threading in
the same application, the present example should work just fine. DC
import os
, sys
, time
, thread
from test
.test_support
import verify
, verbose
, TestSkipped
raise TestSkipped
, "os.fork not defined -- skipping test_fork1"
for i
in range(NUM_THREADS
):
thread
.start_new(f
, (i
,))
verify(a
== range(NUM_THREADS
))
prefork_lives
= alive
.copy()
if sys
.platform
in ['unixware7']:
if alive
[key
] != prefork_lives
[key
]:
spid
, status
= os
.waitpid(cpid
, 0)
"cause = %d, exit = %d" % (status
&0xff, status
>>8) )
time
.sleep(2*SHORTSLEEP
) # Wait for threads to die