F
Frederic Jolliton
Hi,
Here is a small Python program that show curious behavior under
FreeBSD when using threads:
-=-=-=-
$ cat test.py
import os, sys, time, thread
if len( sys.argv ) < 2 :
thread.start_new_thread(lambda : os.system("python test.py x"), ())
time.sleep( 5 )
else :
os.system('echo "Hello, World!"')
print '~system'
-=-=-=-
This program run more or less the following:
python test.py
`- shell -c 'python test.py x'
`- python test.py x
`- shell -c 'echo "Hello World!"'
When run without argument from Linux (Gentoo, kernel 2.4.21, Python
2.2.3), the output is:
-=-=-=-
Hello, World!
~system
<5 seconds pause>
-=-=-=-
But, from FreeBSD, the ouput is:
-=-=-=-
Hello, World!
<5 seconds pause>
-=-=-=-
and, as shown, os.system('echo ...') never return ! (However, the
shell running 'echo' is correctly terminated.)
Tested with the following FreeBSD version:
- 5.0-RELEASE (gcc 3.2.1) Python 2.2.2 and Python 2.3.2
- 4.8-STABLE (gcc 2.95)
Bug, feature or misuse of the thread module ?
Regards,
Here is a small Python program that show curious behavior under
FreeBSD when using threads:
-=-=-=-
$ cat test.py
import os, sys, time, thread
if len( sys.argv ) < 2 :
thread.start_new_thread(lambda : os.system("python test.py x"), ())
time.sleep( 5 )
else :
os.system('echo "Hello, World!"')
print '~system'
-=-=-=-
This program run more or less the following:
python test.py
`- shell -c 'python test.py x'
`- python test.py x
`- shell -c 'echo "Hello World!"'
When run without argument from Linux (Gentoo, kernel 2.4.21, Python
2.2.3), the output is:
-=-=-=-
Hello, World!
~system
<5 seconds pause>
-=-=-=-
But, from FreeBSD, the ouput is:
-=-=-=-
Hello, World!
<5 seconds pause>
-=-=-=-
and, as shown, os.system('echo ...') never return ! (However, the
shell running 'echo' is correctly terminated.)
Tested with the following FreeBSD version:
- 5.0-RELEASE (gcc 3.2.1) Python 2.2.2 and Python 2.3.2
- 4.8-STABLE (gcc 2.95)
Bug, feature or misuse of the thread module ?
Regards,