emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proced: ppid of process ID 0 can be 0


From: Roland Winkler
Subject: Re: proced: ppid of process ID 0 can be 0
Date: Tue, 23 Dec 2008 13:28:22 +0100

> > Indeed, it should be in system-process-attributes which is already
> > OS-dependent.
> 
> If you mean by having no ppid attribute, then that's ambiguous, since
> an attribute can be missing because it is inaccessible for some
> reason, like some kind of failure unrelated to the fact that the
> process is really a root of a tree.

I was offline for a few days. In my humble opinion, the behavior of
pstree is really exactly what I would find useful from a practical
point of view. Pstree's man page says:

  pstree shows running processes as a tree. The tree is rooted at
  either pid or init if pid is omitted. If a user name is specified,
  all process trees rooted at processes owned by that user are
  shown.

Unless I am overlooking something, this means that within a list of
processes (say, the processes owned by $USER or root), *a* root is a
process that doesn't have a parent process within the given list of
processes. This implies that one can get several distinct process
trees from one list of processes. For example, on my GNU/linux system:

- For `pstree 1', the process tree starts with init.

- `pstree 2' shows kthreadd and its children

- Both root and kthreadd have ppid 0. But `pstree 0' gives an error.

- `pstree $USER' gives many unrelated trees, that is, for pstree
  there is generally no such thing like `the' root of `the' process
  tree.

- `pstree root' seems to be a minor inconsistency as it is
  equivalent to `pstree 1'. It seems to ignore the process tree
  rooted in kthreadd.

All this behavior is currently implemented in proced-process-tree
with the only bug that it yields an infinite recursion if
according to system-process-attributes a process is its own parent.
(I guess it is fine that system-process-attributes always reports
the ppid it gets from the OS. An application like proced can handle
such special cases easily.)

Having read the recent contributions to this thread I do not see why
anything more sophisticated could be useful. For all useful
scenarios I can envision, the ppid attribute of
system-process-attributes is all that is needed. To consider process
B the child of process A it is necessary that B has the ppid
attribute with a value that is the pid of A. Any other case (ppid
attribute absent, having a value that points to a nonexistent
process or whatever) doesn't allow one to put A and B one above each
other in a process tree, so it seems to me that it's not worth the
effort to worry about the details in emacs.

Though I didn't read the code of pstree in detail, I'd be very
surprised if it used a more sophisticated scheme.

Roland




reply via email to

[Prev in Thread] Current Thread [Next in Thread]