1

Consider the following script saved as test.py:

from sys import argv, executable
from os import execl

print(argv)
if argv[1] == 'a':
    argv[1] = 'b'
    print('execl')
    execl(executable, 'process_name', *argv)
    print('the interpreter will never get to this line!')

Here is the result of running the script:

$ python3 test.py a
['test.py', 'a']
execl
['test.py', 'b']

I'm curious about what happens to 'process_name'? Does the new python process store it somewhere so it can be read?

I've tried psutil.Process(os.getpid()).name() but it returns 'python.exe' both times.

AXO
  • 8,198
  • 6
  • 62
  • 63

0 Answers0