AKM
AKM

Reputation: 6575

Get process ID with python

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?

Upvotes: 30

Views: 36450

Answers (1)

RichieHindle
RichieHindle

Reputation: 281795

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

Upvotes: 56

Related Questions