From: "Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: lekktu@gmail.com, Stefan Monnier <monnier@iro.umontreal.ca>,
emacs-devel@gnu.org
Subject: Re: proced: ppid of process ID 0 can be 0
Date: Tue, 23 Dec 2008 13:28:22 +0100 [thread overview]
Message-ID: <18768.55654.841724.827529@tfkp04.physik.uni-erlangen.de> (raw)
In-Reply-To: <ulju7czdz.fsf@gnu.org>
> > 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
next prev parent reply other threads:[~2008-12-23 12:28 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-20 2:52 proced: ppid of process ID 0 can be 0 Juanma Barranquero
2008-12-20 3:27 ` Stefan Monnier
2008-12-20 4:31 ` Chong Yidong
2008-12-20 19:10 ` Stefan Monnier
2008-12-20 10:20 ` Juanma Barranquero
2008-12-20 11:34 ` Eli Zaretskii
2008-12-20 19:41 ` Roland Winkler
2008-12-20 21:02 ` Juanma Barranquero
2008-12-20 22:02 ` Eli Zaretskii
2008-12-20 22:41 ` Roland Winkler
2008-12-21 4:15 ` Eli Zaretskii
2008-12-21 4:48 ` Roland Winkler
2008-12-21 19:17 ` Eli Zaretskii
2008-12-21 21:26 ` Juanma Barranquero
2008-12-22 4:09 ` Eli Zaretskii
2008-12-22 10:41 ` Juanma Barranquero
2008-12-22 19:17 ` Eli Zaretskii
2008-12-22 19:26 ` Juanma Barranquero
2008-12-22 2:45 ` Stefan Monnier
2008-12-22 4:08 ` Eli Zaretskii
2008-12-22 4:17 ` Miles Bader
2008-12-22 19:10 ` Eli Zaretskii
2008-12-22 8:54 ` Harald Hanche-Olsen
2008-12-22 10:43 ` Juanma Barranquero
2008-12-22 10:50 ` Harald Hanche-Olsen
2008-12-22 18:03 ` Giorgos Keramidas
2008-12-22 10:59 ` Andreas Schwab
2008-12-22 19:22 ` Eli Zaretskii
2008-12-22 19:37 ` David De La Harpe Golden
2008-12-22 19:59 ` Andreas Schwab
2008-12-22 12:23 ` Stefan Monnier
2008-12-22 19:57 ` Eli Zaretskii
2008-12-22 22:24 ` Stefan Monnier
2008-12-23 4:02 ` Eli Zaretskii
2008-12-23 12:28 ` Roland Winkler [this message]
2008-12-23 14:44 ` Stefan Monnier
2008-12-23 19:12 ` Eli Zaretskii
2008-12-23 20:41 ` Stefan Monnier
2008-12-23 22:34 ` Giorgos Keramidas
2008-12-24 2:34 ` Stefan Monnier
2008-12-24 4:14 ` Eli Zaretskii
2008-12-24 16:47 ` Stefan Monnier
2008-12-24 4:15 ` Eli Zaretskii
2008-12-24 16:47 ` Stefan Monnier
2008-12-24 18:29 ` Eli Zaretskii
2008-12-24 18:55 ` Stefan Monnier
2008-12-24 21:12 ` Eli Zaretskii
2008-12-30 17:11 ` Stefan Monnier
2008-12-30 22:02 ` Eli Zaretskii
2008-12-31 1:40 ` Stefan Monnier
2008-12-22 8:28 ` Ulrich Mueller
2008-12-21 2:18 ` Stefan Monnier
-- strict thread matches above, loose matches on Subject: below --
2008-12-24 7:42 grischka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18768.55654.841724.827529@tfkp04.physik.uni-erlangen.de \
--to=roland.winkler@physik.uni-erlangen.de \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=lekktu@gmail.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).