Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of PID 0 process on Linux #144

Closed
giampaolo opened this issue May 23, 2014 · 11 comments
Closed

Get rid of PID 0 process on Linux #144

giampaolo opened this issue May 23, 2014 · 11 comments

Comments

@giampaolo
Copy link
Owner

From g.rodola on December 27, 2010 17:08:15

As discussed here: https://code.google.com/p/psutil/issues/detail?id=140#c4 
...we're currently providing a PID 0 on Linux, which actually does not exist:

>>> 0 in psutil.get_pid_list()
True
>>> psutil.Process(0)
<psutil.Process (pid=0, name='sched') at 140504839398032>
>>> 

At the beginning of development we hard-coded this behavior in _pslinux.py for 
conformity with other platform implementations but on a second thought I'm not 
sure it's been a good idea. It's not a big deal in pratical terms but a user 
willing to get the number of currently running processes would get an erroneous value.
My vote is to get rid of all 0 pid code in the next version.
Jay, what do you think?

Original issue: http://code.google.com/p/psutil/issues/detail?id=144

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on December 27, 2010 08:08:47

Summary: Get rid of PID 0 process on Linux

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on December 27, 2010 11:49:31

I personally think we should keep it, but document it since it provides a way 
to get information for the "kernel" process even before init, and it fits 
nicely with other platforms. As long as it's adequately documented I think we 
should keep it in place.

@giampaolo
Copy link
Owner Author

From g.rodola on July 02, 2011 11:21:33

> it provides a way to get information for the "kernel" process even before init

What do you mean?
As of now we are "faking" all the return values with bogus data such as [], "", 
or AccessDenied exception.

@giampaolo
Copy link
Owner Author

From g.rodola on September 29, 2011 16:26:32

I'd like to move forward with this and figure out what to do.
My previous comment still stands: we're currently faking all the returned info 
for no other reason than to comply with those platforms were pid 0 is an actual 
process pid.

Also, pid 0 is not shown by cmdline tools such as ps, top and iotop, adding 
unnecessary burden in case one wants to clone those tools (see issue 213 - 
iotop clone).

@giampaolo
Copy link
Owner Author

From jloden.n...@gmail.com on September 29, 2011 17:10:24

That's fine, you can remove it if you want to. I think it makes sense since 
there IS debatably a PID 0 / sched process on Linux, but it's not a critical feature.

@giampaolo
Copy link
Owner Author

From g.rodola on September 30, 2011 01:05:54

I've been trying to search info about this and results aren't exhaustive.
AFAICT, ps cannot provide any info:

giampaolo@ubuntu:~$ ps -p 0
ERROR: Process ID out of range.
giampaolo@ubuntu:~$ ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Sep29 ?        00:00:00 /sbin/init
root         2     0  0 Sep29 ?        00:00:00 [kthreadd]
...

Other than that, even is there is a pid 0, we are not returning any information 
about it aside from an hard coded name ("sched"); this is my real point.

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on September 30, 2011 05:24:36

> Other than that, even is there is a pid 0, we are not returning any 
information about it 
> aside from an hard coded name ("sched"); this is my real point.

And the boot time of the system as the start time of the process, IIRC. 

Again, it's not a critical feature, we can remove it if you want, I don't think 
anyone will have a problem with it.

@giampaolo
Copy link
Owner Author

From g.rodola on September 30, 2011 07:55:54

Checked in as r1141 .

Status: FixedInSVN
Labels: Milestone-0.3.1 Portability

@giampaolo
Copy link
Owner Author

From g.rodola on October 21, 2011 16:44:17

Labels: -Milestone-0.3.1

@giampaolo
Copy link
Owner Author

From g.rodola on October 21, 2011 16:45:26

Labels: Milestone-0.4.0

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 03:57:51

Updated csets after the SVN -> Mercurial migration: r1141 == revision 
9abda73cc8d1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant