Skip to content

Instantly share code, notes, and snippets.

@ilius
Last active January 1, 2020 05:38
Show Gist options
  • Save ilius/621daad094983a33826e to your computer and use it in GitHub Desktop.
Save ilius/621daad094983a33826e to your computer and use it in GitHub Desktop.
import os
import psutil
ps_by_pid = dict([(p.pid, p) for p in psutil.get_process_list()])
my_pid = os.getpid()
#my_proc = ps_by_pid[my_pid]
my_proc = psutil.Process(my_pid)
my_cmd = my_proc.cmdline() ## list, for example: ['python3', 'psutil-example.py']
print(my_pid, my_cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment