Get process ID with python

Question:

How to get the current process id with Python on Windows?

There is this function os.geteuid(), but it only works with Linux/Unix. Could someone explain what is the Pythonic way to get the current process id on windows?

Asked By: AKM

||

Answers:

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…?

Answered By: RichieHindle
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.