Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7069

subprocess.Popen fails to set the name of executable

$
0
0

According to the documentation of Popen, it seems possible, in POSIX systems, to set the name of the process as it is returned by ps:

The executable argument specifies a replacement program to execute. It is very seldom needed. When shell=False , executable replaces the program to execute specified by args. However, the original args is still passed to the program. Most programs treat the program specified by args as the command name, which can then be different from the program actually executed. On POSIX, the args name becomes the display name for the executable in utilities such as ps.

On my Ubuntu 22.04 machine, if I run the following python script:

import subprocesswith subprocess.Popen(["foo", "10"], executable="sleep", shell=False) as process:    pass

and then run ps -ae in another terminal, the last lines of output are

  22854 ?        00:00:00 python3.10  22857 ?        00:00:00 sleep  22860 pts/0    00:00:00 ps

I would expect to see foo instead of sleep. Could you please explain me what I am getting wrong?


Viewing all articles
Browse latest Browse all 7069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>