kiranvizru / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

pid_exists(0) lies on POSIX #457

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
>>> import psutil
>>> 0 in psutil.get_pids()
False
>>> psutil.pid_exists(0)
True
>>> 

This is similar to issue 23 of 4 years ago.
This happens because internally we use os.kill() and according to "man 2 kill":

> If pid equals 0, then sig is sent to every process 
> in the process group of the calling process.

...which is definitively not what we want.
In case of PID 0 we should just "return 0 in get_pids()".

Original issue reported on code.google.com by g.rodola on 17 Dec 2013 at 1:55

GoogleCodeExporter commented 9 years ago
Fixed in revision 0fe8e5eb7fbe.

Original comment by g.rodola on 17 Dec 2013 at 2:41

GoogleCodeExporter commented 9 years ago
Closing out as fixed as 2.0.0 version is finally out.

Original comment by g.rodola on 10 Mar 2014 at 11:36