From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Detecting a running process in Elisp
Date: Sat, 27 Jul 2013 10:43:08 +0300 [thread overview]
Message-ID: <83hafgzbw3.fsf@gnu.org> (raw)
In-Reply-To: <87bo5p2g58.fsf@informatimago.com>
> From: "Pascal J. Bourguignon" <pjb@informatimago.com>
> Date: Fri, 26 Jul 2013 22:57:39 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> From: "Pascal J. Bourguignon" <pjb@informatimago.com>
> >> Date: Fri, 26 Jul 2013 18:58:15 +0200
> >>
> >> > There's list-system-processes to list all of the processes, and
> >> > process-attributes to examine their attributes, including name,
> >> > command line, etc.
> >>
> >> And what is the function to lock the system so that the list of PIDs
> >> returned by list-system-processes is consistent with the actual
> >> processes in the system when you call process-attributes on them?
> >
> > How is this relevant to the OP's question?
>
> It is relevant to the answer, to the proposed API.
Fair enough, then please explain what problem(s) you have in mind.
If you are thinking about a process that was alive when
list-system-processes was called, but is no longer there when
process-attributes is called for its PID, the process-attributes is
already immune to that: it will return nil.
In general, any method that walks the list of the processes, querying
the OS about each one, is prone to the same issues. The only way to
avoid that is to have a system call that will produce a single
coherent snapshot of the processes, together with every one of their
attributes you will ever want to know about. If the OS doesn't
provide such a system call, there's nothing an application can do
better than cope with processes that disappear during the walk.
And, FWIW, "ps -A" does not "lock" the system, either, so it suffers
from the same issues.
In practical terms, such "disappearing" processes are not a concern,
since they are not different from a process that exited just before
you called list-system-processes. Unless you want to write an OS
monitor in Emacs Lisp, this shouldn't bother you.
next prev parent reply other threads:[~2013-07-27 7:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-26 15:26 Detecting a running process in Elisp gentsquash
2013-07-26 15:37 ` Eli Zaretskii
2013-07-26 15:50 ` Drew Adams
2013-07-26 15:54 ` Eli Zaretskii
[not found] ` <<83siz1z58a.fsf@gnu.org>
2013-07-26 16:17 ` Drew Adams
2013-07-26 18:49 ` Eli Zaretskii
[not found] ` <<83mwp9yx5f.fsf@gnu.org>
2013-07-26 18:54 ` Drew Adams
[not found] ` <mailman.1854.1374853118.12400.help-gnu-emacs@gnu.org>
2013-07-26 16:58 ` Pascal J. Bourguignon
2013-07-26 18:33 ` Eli Zaretskii
[not found] ` <mailman.1870.1374863596.12400.help-gnu-emacs@gnu.org>
2013-07-26 20:57 ` Pascal J. Bourguignon
2013-07-27 7:43 ` Eli Zaretskii [this message]
2013-07-26 23:18 ` gentsquash
2013-07-26 23:57 ` Drew Adams
2013-07-27 8:48 ` Eli Zaretskii
2013-07-27 9:07 ` Peter Dyballa
2013-07-27 10:20 ` Pascal J. Bourguignon
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83hafgzbw3.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.