[Pythonmac-SIG] Warning: The process has forked and you cannot use this CoreFoundation functionality safely.

Russell E. Owen rowen at u.washington.edu
Wed Jan 14 22:51:30 CET 2009


A good question, and in the process of answering it I found that problem 
is caused by running a "Tiger" version of SAOImage DS9 on "Leopard". 
These can be downloaded from:
<http://hea-www.harvard.edu/RD/ds9/>

Python version is 2.5.2 (the version from python.org).
I'm no an Intel Mac running 10.5.6.
This trivial test case shows the problem:

import subprocess
args = ('/Applications/SAOImage DS9.app/Contents/MacOS/ds9', '-title', 
'foo', '-port', '0')
subprocess.Popen(args=args)

This works correctly on Leopard if running a Leopard version of the DS9. 
But if I use a Tiger version of DS9 then after the Popen "call" returns 
I see a host of these warning messages:

The process has forked and you cannot use this CoreFoundation 
functionality safely. You MUST exec().
Break on 
__THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONA
LITY___YOU_MUST_EXEC__() to debug.

(I have verified this with DS9 5.4 -- Leopard and Tiger versions -- but 
I first found it out because I had an older Tiger DS9 that I had not 
upgraded when I switched to Leopard).

-- Russell

P.S. As a result of this test I am skeptical of the Tiger version of 
DS9, because the message warns of something that should not have been 
done in either MacOS X 10.4 or 10.5 -- even though only 10.5 warns about 
it.

In article 
<65fadfc30901092026l1b499edfi42fcd59afe66d409 at mail.gmail.com>,
 "Nehemiah Dacres" <vivacarlie at gmail.com> wrote:

> python version please and where might I find this code?
> fork(3) is the unix system call that copies the program and one becomes a
> child process and another a parent (which is supposed to wait on the child).
> The child process normally calls a function from the exec(2) family soon
> afterward. Leopard is probably being anal because until exec, that is 2
> programms with the same amount of address size and Core Foundation may not
> be able to handel that. The error
> 
> >
> > The process has forked and you cannot use this CoreFoundation
> > functionality safely. You MUST exec().
> >
> uses the word 'this', which implies it gave you the CoreFoundation API call
> that triggered the warning.
> 
> >
> > Is there some Mac-safe way to start the ds9 command-line application
> > from my python module? I don't really know what it means to "run an
> > exec*() function after a fork" and didn't think I was forking anything
> > anyway -- I'm trying to start an independent process. I fear that the
> > fork may be in ds9 itself and that there's nothing I can do, but I hope
> > I'm wrong.
> 
> 
> It is evident that the program is handeling something in a Mac OS Classic
> way that should be handled in a BSD way. That could be either Python's fault
> or the progammer.



More information about the Pythonmac-SIG mailing list