Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Process.name() cache may be outdated #692
psutil cache the process name based on (pid, creation_time), but in case of exec it could change.
I can reproduce this issue with:
The loop used is :
Note: the cmdline() - which is not cached - show the new name.
A way to request name without using cache may be valuable.
I have the same problem with checkpointing and restarting processes. During restart the process name is the name of the checkpoint/restart tool (CRIU) and once the process has been restored it changes to the program being restarted. So sometimes I get 'criu' as process name and sometimes the actual process name after the restore. It depends on the point in time at which the loop over psutil.process_iter() is run.