How to get the current process id with python on windows?
there are this function os.geteuid() but its only works with linux/unix could someone tell what it the pythonic way to get the current process id on windows.
os. getpid () Return the current process id. os. getppid ()
In Python, a process is an instance of the Python interpreter that executes Python code. In Python, the first process created when we run our program is called the MainProcess. It is also a parent process and may be called the main parent process. The main process will create the first child process or processes.
The easiest way to find out if process is running is run ps aux command and grep process name. If you got output along with process name/pid, your process is running.
Do you really want the process ID? Then the answer is this:
>>> import os
>>> os.getpid()
5328
on either Windows or Unix (documentation of os.getpid
).
os.geteuid()
doesn't get the process ID, which makes me wonder whether you're really asking a different question...?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With