[New-bugs-announce] [issue6800] os.exec* raises "OSError: [Errno 45] Operation not supported" in a multithreaded application

Reid Kleckner report at bugs.python.org
Sat Aug 29 05:19:48 CEST 2009

New submission from Reid Kleckner <rnk at mit.edu>:

The test case is attached.  On Mac OS X (and presumably FreeBSD, which
has the same behavior) when you try to exec from a process that has any
other threads in it, you get an OSError, "Operation not supported". 
Here's the output on my MacBook:

Traceback (most recent call last):
  File "daemon_exec.py", line 16, in <module>
  File "daemon_exec.py", line 13, in main
    os.execl('echo', 'hello world')
line 312, in execl
    execv(file, args)
OSError: [Errno 45] Operation not supported

And on my Linux box:

hello world

Here's a similar bug that OCaml had to deal with:

I think it's reasonable for Python to declare this to be a limitation of
the OS, but considering that the other thread could be a daemon thread
that the user doesn't really care about, I think it would be reasonable
for Python to kill the other threads in the process before execing. 
That's what happens on Linux, anyway.

I ran into this problem while trying to add a persistent background
compilation thread to unladen swallow, and wondered if having any other
threads would trigger the same exception.

It's tempting to just write this off, but I figured it should be
documented or left open as a low priority defect.

assignee: ronaldoussoren
components: Macintosh
files: daemon_exec.py
messages: 92054
nosy: rnk, ronaldoussoren
severity: normal
status: open
title: os.exec* raises "OSError: [Errno 45] Operation not supported" in a multithreaded application
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file14798/daemon_exec.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list