Cross-platform way to get PIDs by process name in python

后端 未结 8 1088
后悔当初
后悔当初 2020-12-02 09:35

Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jyth

8条回答
  •  情话喂你
    2020-12-02 10:11

    There isn't, I'm afraid. Processes are uniquely identified by pid not by name. If you really must find a pid by name, then you will have use something like you have suggested, but it won't be portable and probably will not work in all cases.

    If you only have to find the pids for a certain application and you have control over this application, then I'd suggest changing this app to store its pid in files in some location where your script can find it.

提交回复
热议问题