python / cpython

The Python programming language
https://www.python.org/
Other
60.9k stars 29.4k forks source link

fork problem with Python-2.1 #34541

Closed c16475b3-4c3f-4f8d-8039-7db4db4c0759 closed 22 years ago

c16475b3-4c3f-4f8d-8039-7db4db4c0759 commented 23 years ago
BPO 426960
Nosy @loewis, @Yhg1s

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = created_at = labels = ['extension-modules'] title = 'fork problem with Python-2.1' updated_at = user = 'https://bugs.python.org/arminsteinhoff' ``` bugs.python.org fields: ```python activity = actor = 'loewis' assignee = 'none' closed = True closed_date = None closer = None components = ['Extension Modules'] creation = creator = 'arminsteinhoff' dependencies = [] files = [] hgrepos = [] issue_num = 426960 keywords = [] message_count = 5.0 messages = ['4852', '4853', '4854', '4855', '4856'] nosy_count = 4.0 nosy_names = ['loewis', 'jhylton', 'twouters', 'arminsteinhoff'] pr_nums = [] priority = 'low' resolution = 'wont fix' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue426960' versions = [] ```

c16475b3-4c3f-4f8d-8039-7db4db4c0759 commented 23 years ago

I have a strange problem with Python2.1 running QNX6. The test script test_fork1.py returns with following result:

# python -t test_fork1.py
/* sys.path include in script ... */
['', '/usr/local/lib/python2.1', '/usr/local/lib/python2.1/Lib/lib-tk',
'/usr/local/lib/python2.1/lib/python2.1', '/usr/local/
lib/python2.1/lib/python2.1/plat-qnx6',
'/usr/local/lib/python2.1/lib/python2.1/lib-tk',
'/usr/local/lib/python2.1/lib/python2 .1/lib-dynload']
Traceback (most recent call last):
  File "test_fork1.py", line 76, in ?
    main()
  File "test_fork1.py", line 55, in main
    cpid = os.fork()
OSError: [Errno 89] Function not implemented

That's very strange ... because it works in the interactive mode =:-( ----------------------------------------------------------------------

# python
Python 2.1 (#16, May 11 2001, 18:37:57)
[GCC 2.95.2 19991024 (release)] on qnx6
Type "copyright", "credits" or "license" for more information.
>>> import sys, os
>>>sys.path
['', '/usr/local/lib/python2.1', '/usr/local/lib/python2.1/Lib/lib-tk',
'/usr/local/lib/python2.1/lib/python2.1',
'/usr/local/lib/python2.1/lib/python2.1/plat-qnx6',
'/usr/local/lib/python2.1/lib/python2.1/lib-tk',
'/usr/local/lib/python2.1/lib/python2 .1/lib-dynload']
>>>
>>> os.fork
<built-in function fork>
>>> os.fork()
6512990

Any ideas where to look?

Armin

03bde425-37ce-4291-88bd-d6cecc46a30e commented 23 years ago

Logged In: YES user_id=31392

test_fork1 tests the behavior of threads across a fork (why this is important is not entirely clear to me). Perhaps the problem you see is that fork() behaves differently in the presence of threads.

Did you try this?
>>> import test.test_fork1

Is os.name == "posix" on your system? Or does fork() come from somewhere other than the posix module?

c16475b3-4c3f-4f8d-8039-7db4db4c0759 commented 23 years ago

Logged In: YES user_id=64602

Hello Jeremy,

here are the reponses to os.name and import test.test_fork1:

# python
Python 2.1 (#16, May 11 2001, 18:37:57)
[GCC 2.95.2 19991024 (release)] on qnx6
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> os.name
'posix'
>>> import test.test_fork1
['', '/root/Python-2.1/Lib', '/root/Python-2.1/Lib/Lib/lib-tk', '/root/Python-2.1/Lib/lib/python2.1', 
'/root/Python-2.1/Lib/lib/python2.1/plat-qnx6', '/root/Python-2.1/Lib/lib/python2.1/lib-tk', 
'/root/Python-2.1/Lib/lib/python2.1/lib-dynload']
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/root/Python-2.1/Lib/test/test_fork1.py", line 76, in ?
main()
File "/root/Python-2.1/Lib/test/test_fork1.py", line 55, in main
cpid = os.fork()
OSError: [Errno 89] Function not implemented
>>>

But 'fork' is of course implemented ...

Armin

Yhg1s commented 23 years ago

Logged In: YES user_id=34209

I suspect Jeremy is right, and this bug is because of the mixing of threads and fork(). You could test that by doing what test_fork1 also does: starting a few threads, and then calling fork(). I'm fairly certain you'll end up getting the same error, and that it'll be documented somewhere in your system documentation.

61337411-43fc-4a9c-b8d5-4060aede66d0 commented 22 years ago

Logged In: YES user_id=21627

This problem is documented in

http://qdn.qnx.com/support/docs/neutrino_qrp/prog/process.html

# As of this writing, you can't use fork() and forkpty() # in a process that has threads. The fork() and forkpty() # functions will simply return -1 and errno will contain # ENOSYS.

Thus, I close this as "Won't fix".