help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Detecting a running process in Elisp


From: Eli Zaretskii
Subject: Re: Detecting a running process in Elisp
Date: Sat, 27 Jul 2013 10:43:08 +0300

> 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.



reply via email to

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