[issue7774] sys.executable: wrong location if zeroth command argument is modified.

STINNER Victor report at bugs.python.org
Thu Mar 11 03:18:47 CET 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

Twisted uses the following code (on UNIX-like OS):

def launchWithName(name):
    if name and name != sys.argv[0]:
        exe = os.path.realpath(sys.executable)
        log.msg('Changing process name to ' + name)
        os.execv(exe, [name, sys.argv[0], '--originalname'] + sys.argv[1:])

Twisted doesn't care if sys.executable is invalid when argv[0] has been changed. sys.executable is only used to change the process name (sys.executable is used before argv[0] is modified).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7774>
_______________________________________


More information about the Python-bugs-list mailing list