[Python-Dev] Pondering some changes to python.c... (original) (raw)
Guido van Rossum guido@python.org
Mon, 08 Apr 2002 17:46:24 -0400
- Previous message: [Python-Dev] Pondering some changes to python.c...
- Next message: [Python-Dev] Pondering some changes to python.c...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Apr 08, 2002 at 04:51:57PM -0400, Guido van Rossum wrote: >When I run a Python script that has a #! directly, ps doesn't show me >the "python" part -- only the script name. This is in Linux (Red Hat >7.2). Maybe it's different for you?
[Sean]
I was told at one point that "#!/usr/bin/env python" was the preferred she-bang incantation. However, calling it directly on my 7.2 box seems to show Python in either case:
guin:tmp$ printf '#!/usr/bin/python\nimport time; time.sleep(5)' >testscript guin:tmp$ ./testscript & ps -awlx | grep testscript 000 500 8297 6741 10 0 2256 1192 dosel S pts/0 0:00 /usr/bin/python ./testscript guin:tmp$ printf '#!/usr/bin/env python\nimport time; time.sleep(5)' >testscript guin:tmp$ ./testscript & ps -awlx | grep testscript 000 500 8300 6741 9 0 2256 1192 dosel S pts/0 0:00 python ./testscript
Alas, yes. Default ps shows the script name, but ps -f does indeed show the Python interpreter.
>I'm not sure I understand. If you have the argc/argv/environ set, why >do you need to know &argc and &argv?
On Linux and a few other systems, setting the ps string requires re-writing the block of memory starting at argv[0]. If the data in envp is allocated next to argv, you can also make use of that (so that you can write strings longer than "python testscript" in length). The typical way of doing this involves first making a copy of argv and envp for the process to continue using, because otherwise argv suddenly becomes something entirely different than what it originally was. So, we need to know &argv so that we can hand back the new location.
Sigh. The more I hear about this, the more I think, too ugly, this doesn't belong in Python.
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Pondering some changes to python.c...
- Next message: [Python-Dev] Pondering some changes to python.c...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]