strange subprocess behavior when calling ps

Roger Davis rbd at hawaii.edu
Wed Nov 17 05:05:17 CET 2010


Thanks, Chris, you're at least on the right track. I did upgrade from
python.org and the python in my shell PATH is /Library/Frameworks/
Python.framework/Versions/2.6/bin/python:

% python
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

/usr/bin/python is the Apple-distributed 2.6.1:

% /usr/bin/python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin

This still doesn't explain the behavior to me, however. In either case
python is supposed to be forking a child process with a specific
executable (/bin/ps) and a specific argument list (-e) and reading
that command's output lines. Why should those output lines be
different whether I use 2.6.1, 2.6.6 or 8.9.10 for that matter? In
fact, this makes the problem that much worse -- the newer python 2.6.6
is the one producing the incorrect output. Changing the first line of
the script to read

#!/Library/Frameworks/Python.framework/Versions/2.6/bin/python

does not help, it still prints out the wrong output whether I do

% ./pid.py

or

% /Library/Frameworks/Python.framework/Versions/2.6/bin/python ./
pid.py

Any ideas?

Thanks!



More information about the Python-list mailing list