summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-03-02 07:04:51 (GMT)
committerGuido van Rossum <guido@python.org>2001-03-02 07:04:51 (GMT)
commitb7fe432a8863d876670f6753abb9f92f20bea399 (patch)
tree2ff1cb144676e01f4bc972daa3e55e9897bb00d5
parent258ccd41264f3a77a767553240641a90e3ab5f0b (diff)
downloadcpython-b7fe432a8863d876670f6753abb9f92f20bea399.zip
cpython-b7fe432a8863d876670f6753abb9f92f20bea399.tar.gz
cpython-b7fe432a8863d876670f6753abb9f92f20bea399.tar.bz2
Fix by Donn Cave for BeOS (SF #403642):
UNIX style fork/execve/wait are not fully compatible with thread support on BeOS. For Python, that means neither fork() from import nor import from a fork work reliably. os._execvpe() does the latter, importing tempfile to set up a tantalizing target for hackers. This patch replaces both the tempfile name generation and the exec that uses it, in case we're on BeOS. Need this for setup:distutils:execvp(); symptoms are random crashes and internal BeOS error messages about th name, in case we're on BeOS. It's an issue because setup.py + distutils calls os.execvp(); symptoms are random crashes during setup.py, and internal BeOS error messages about thread IDs.
-rw-r--r--Lib/os.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 201aa9d..84722af 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -322,10 +322,19 @@ def _execvpe(file, args, env=None):
envpath = defpath
PATH = envpath.split(pathsep)
if not _notfound:
- import tempfile
- # Exec a file that is guaranteed not to exist
- try: execv(tempfile.mktemp(), ('blah',))
- except error, _notfound: pass
+ if sys.platform[:4] == 'beos':
+ # Process handling (fork, wait) under BeOS (up to 5.0)
+ # doesn't interoperate reliably with the thread interlocking
+ # that happens during an import. The actual error we need
+ # is the same on BeOS for posix.open() et al., ENOENT.
+ try: unlink('/_#.# ## #.#')
+ except error, _notfound: pass
+ else:
+ import tempfile
+ t = tempfile.mktemp()
+ # Exec a file that is guaranteed not to exist
+ try: execv(t, ('blah',))
+ except error, _notfound: pass
exc, arg = error, _notfound
for dir in PATH:
fullname = path.join(dir, file)