* Detecting a running process in Elisp
@ 2013-07-26 15:26 gentsquash
2013-07-26 15:37 ` Eli Zaretskii
` (3 more replies)
0 siblings, 4 replies; 16+ messages in thread
From: gentsquash @ 2013-07-26 15:26 UTC (permalink / raw)
To: help-gnu-emacs
I have a process "ScidvsMac" which I'd like to detect in
Elisp. I'm currently using
(search "ScidvsMac" (shell-command-to-string "ps -A"))
but is there something cleaner?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
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
` (2 subsequent siblings)
3 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-26 15:37 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 26 Jul 2013 08:26:25 -0700 (PDT)
> From: gentsquash@gmail.com
>
> I have a process "ScidvsMac" which I'd like to detect in
> Elisp. I'm currently using
>
> (search "ScidvsMac" (shell-command-to-string "ps -A"))
>
> but is there something cleaner?
There's list-system-processes to list all of the processes, and
process-attributes to examine their attributes, including name,
command line, etc.
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: Detecting a running process in Elisp
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>
[not found] ` <mailman.1854.1374853118.12400.help-gnu-emacs@gnu.org>
2013-07-26 23:18 ` gentsquash
3 siblings, 2 replies; 16+ messages in thread
From: Drew Adams @ 2013-07-26 15:50 UTC (permalink / raw)
To: gentsquash, help-gnu-emacs
> I have a process "ScidvsMac" which I'd like to detect in
> Elisp. I'm currently using
> (search "ScidvsMac" (shell-command-to-string "ps -A"))
> but is there something cleaner?
Without knowing anything about processes in Elisp, I tried
using apropos "processes" (apropos "process" had too many hits).
That led me to `list-processes', which led me to `list-processes--refresh'.
That led me to `process-list', which I imagine you can use to get
what you want. Each element of `process-list' is supposedly a
process object (the doc is not terrific for `process-list'), which
means you can use functions such as `process-buffer', `process-name',
`process-type', `process-status', and `process-attributes' on it.
HTH. Remember: `apropos' and its friends are your friends.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
2013-07-26 15:50 ` Drew Adams
@ 2013-07-26 15:54 ` Eli Zaretskii
[not found] ` <<83siz1z58a.fsf@gnu.org>
1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-26 15:54 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 26 Jul 2013 08:50:35 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
>
> Without knowing anything about processes in Elisp, I tried
> using apropos "processes" (apropos "process" had too many hits).
>
> That led me to `list-processes', which led me to `list-processes--refresh'.
>
> That led me to `process-list', which I imagine you can use to get
> what you want.
These are for processes that Emacs launched. Other processes running
on the system will not show.
> HTH. Remember: `apropos' and its friends are your friends.
Right, because list-system-processes is also there.
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: Detecting a running process in Elisp
[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>
0 siblings, 2 replies; 16+ messages in thread
From: Drew Adams @ 2013-07-26 16:17 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs
> > Without knowing anything about processes in Elisp, I tried
> > using apropos "processes" (apropos "process" had too many hits).
> >
> > That led me to `list-processes', which led me to `list-processes--
> > refresh'. That led me to `process-list', which I imagine you can
> > use to get what you want.
>
> These are for processes that Emacs launched. Other processes running
> on the system will not show.
>
> > HTH. Remember: `apropos' and its friends are your friends.
>
> Right, because list-system-processes is also there.
Good correction - `list-system-processes', not `list-processes' or
`process-list'.
[Too bad, BTW, that the doc string of `list-processes' says
"Display a list of all processes" - N.B. "ALL", not all processes
that Emacs has launched.
It mentions exclusion of certain processes, depending on argument
QUERY-ONLY and whether exited or signaled, but it does not go beyond
that to characterize which other processes might be excluded.]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
[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>
0 siblings, 2 replies; 16+ messages in thread
From: Pascal J. Bourguignon @ 2013-07-26 16:58 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Fri, 26 Jul 2013 08:26:25 -0700 (PDT)
>> From: gentsquash@gmail.com
>>
>> I have a process "ScidvsMac" which I'd like to detect in
>> Elisp. I'm currently using
>>
>> (search "ScidvsMac" (shell-command-to-string "ps -A"))
>>
>> but is there something cleaner?
>
> 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?
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
You know you've been lisping too long when you see a recent picture of George
Lucas and think "Wait, I thought John McCarthy was dead!" -- Dalek_Baldwin
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
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>
1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-26 18:33 UTC (permalink / raw)
To: help-gnu-emacs
> 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?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
2013-07-26 16:17 ` Drew Adams
@ 2013-07-26 18:49 ` Eli Zaretskii
[not found] ` <<83mwp9yx5f.fsf@gnu.org>
1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-26 18:49 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 26 Jul 2013 09:17:55 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
>
> [Too bad, BTW, that the doc string of `list-processes' says
> "Display a list of all processes" - N.B. "ALL", not all processes
> that Emacs has launched.
Fixed.
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: Detecting a running process in Elisp
[not found] ` <<83mwp9yx5f.fsf@gnu.org>
@ 2013-07-26 18:54 ` Drew Adams
0 siblings, 0 replies; 16+ messages in thread
From: Drew Adams @ 2013-07-26 18:54 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs
> > [Too bad, BTW, that the doc string of `list-processes' says
> > "Display a list of all processes" - N.B. "ALL", not all processes
> > that Emacs has launched.
>
> Fixed.
That was quick. Thx.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
[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
0 siblings, 1 reply; 16+ messages in thread
From: Pascal J. Bourguignon @ 2013-07-26 20:57 UTC (permalink / raw)
To: help-gnu-emacs
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.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
You know you've been lisping too long when you see a recent picture of George
Lucas and think "Wait, I thought John McCarthy was dead!" -- Dalek_Baldwin
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
2013-07-26 15:26 Detecting a running process in Elisp gentsquash
` (2 preceding siblings ...)
[not found] ` <mailman.1854.1374853118.12400.help-gnu-emacs@gnu.org>
@ 2013-07-26 23:18 ` gentsquash
2013-07-26 23:57 ` Drew Adams
` (3 more replies)
3 siblings, 4 replies; 16+ messages in thread
From: gentsquash @ 2013-07-26 23:18 UTC (permalink / raw)
To: help-gnu-emacs
Thanks, all, for your replies. I realize that I didn't give
enough information. I'm running
GNU Emacs 22.3.1 (i386-apple-darwin9.8.0, Carbon Version 1.6.0)
under Mac OS. It appears there is no `list-system-processes' in Emacs22.
[Aside: I've been quite happy with Carbon Emacs, but my understanding
is that it is no longer updated. Is there a recommended version of
Emacs23 (or 24?) for Mac users who are used to Carbon Emacs?]
I had run `apropos' on "shell" and "command", but inexplicably didn't
run it on "process". When I did that now, I didn't see -in Emacs22-
a cmd for listing the system processes.
/--------------------------------------------------------\
Eli Zaretskii
> From: Drew Adams <drew....@oracle.com>
> ... That led me to `process-list', which I imagine you
> can use to get what you want.
These are for processes that Emacs launched. Other processes
running on the system will not show.
\________________________________________________________/
In a shell, inside Emacs, I can run
open /Applications/ChessJK/ScidvsMac.app
However, I don't think this counts as launching-from-Emacs, and
the ScidvsMac process does not show up in (process-list).
Running `apropos' on "mac", and on "process", I did find
`mac-process-activate', but this doesn't seem to be what I need.
So... If I wanted to "launch" ScidvsMac (a chess database program)
from Emacs, under Mac OS, how would I do it?
Thanks again, everyone. -Jonathan
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: Detecting a running process in Elisp
2013-07-26 23:18 ` gentsquash
@ 2013-07-26 23:57 ` Drew Adams
2013-07-27 8:48 ` Eli Zaretskii
` (2 subsequent siblings)
3 siblings, 0 replies; 16+ messages in thread
From: Drew Adams @ 2013-07-26 23:57 UTC (permalink / raw)
To: gentsquash, help-gnu-emacs
> I had run `apropos' on "shell" and "command", but inexplicably didn't
> run it on "process". When I did that now, I didn't see -in Emacs22-
> a cmd for listing the system processes.
You probably did this anyway, but just a reminder that there are
several apropos commands, in particular besides `apropos-command'.
In this case you don't want to look only for Emacs *commands* with
`process' in the name; you want to look for functions in general, and
perhaps even variables too.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
2013-07-26 20:57 ` Pascal J. Bourguignon
@ 2013-07-27 7:43 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-27 7:43 UTC (permalink / raw)
To: help-gnu-emacs
> 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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
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
3 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2013-07-27 8:48 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 26 Jul 2013 16:18:42 -0700 (PDT)
> From: gentsquash@gmail.com
>
> Thanks, all, for your replies. I realize that I didn't give
> enough information. I'm running
>
> GNU Emacs 22.3.1 (i386-apple-darwin9.8.0, Carbon Version 1.6.0)
>
> under Mac OS. It appears there is no `list-system-processes' in Emacs22.
Indeed. Why not upgrade?
> Eli Zaretskii
> > From: Drew Adams <drew....@oracle.com>
> > ... That led me to `process-list', which I imagine you
> > can use to get what you want.
>
> These are for processes that Emacs launched. Other processes
> running on the system will not show.
> \________________________________________________________/
>
>
> In a shell, inside Emacs, I can run
>
> open /Applications/ChessJK/ScidvsMac.app
>
> However, I don't think this counts as launching-from-Emacs
It doesn't. Emacs subprocesses are those created by call-process,
call-process-region, and start-process.
> So... If I wanted to "launch" ScidvsMac (a chess database program)
> from Emacs, under Mac OS, how would I do it?
Use start-process. There are commands that use that, from Dired, for
example.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
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
3 siblings, 0 replies; 16+ messages in thread
From: Peter Dyballa @ 2013-07-27 9:07 UTC (permalink / raw)
To: gentsquash; +Cc: help-gnu-emacs
Am 27.07.2013 um 01:18 schrieb gentsquash@gmail.com:
> [Aside: I've been quite happy with Carbon Emacs, but my understanding
> is that it is no longer updated. Is there a recommended version of
> Emacs23 (or 24?) for Mac users who are used to Carbon Emacs?]
Carbon Emacs is dead. Since years. There are some compiled versions of the NS variants of GNU Emacs 24.3 and 24.3.50 (development version) around. Aquamacs Emacs is among them. The best approach, IMO, is to get the sources of GNU Emacs 24.3 and then apply the patches from YAMAMOTO Mitsuharu, available from /ftp:anonymous@ftp.math.s.chiba-u.ac.jp:/emacs (TRAMP syntax), to compile the "AppKit" variant with a much deeper integration into Mac OS X.
--
Greetings
Pete
Claiming that the Macintosh is inferior to Windows because most people use Windows, is like saying that all other restaurants serve food that is inferior to McDonald's.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Detecting a running process in Elisp
2013-07-26 23:18 ` gentsquash
` (2 preceding siblings ...)
2013-07-27 9:07 ` Peter Dyballa
@ 2013-07-27 10:20 ` Pascal J. Bourguignon
3 siblings, 0 replies; 16+ messages in thread
From: Pascal J. Bourguignon @ 2013-07-27 10:20 UTC (permalink / raw)
To: help-gnu-emacs
gentsquash@gmail.com writes:
> Thanks, all, for your replies. I realize that I didn't give
> enough information. I'm running
>
> GNU Emacs 22.3.1 (i386-apple-darwin9.8.0, Carbon Version 1.6.0)
>
> under Mac OS. It appears there is no `list-system-processes' in Emacs22.
Well emacs hasn't been updated for Mac OS for at least 13 years now.
You're really using an old system.
Now if you mean Mac OS X (i386-apple-darwin9.8.0), then my advice is to
use http://www.emacsformacosx.com/
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
You know you've been lisping too long when you see a recent picture of George
Lucas and think "Wait, I thought John McCarthy was dead!" -- Dalek_Baldwin
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2013-07-27 10:20 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.