[Top][All Lists]

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

Re: How to communicate with a running external process with

From: Thorsten Jolitz
Subject: Re: How to communicate with a running external process with
Date: Tue, 23 Jul 2013 09:59:35 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

"Buchs, Kevin J." <> writes:

Hi Kevin,

> Your questions and responses suggest that maybe you are not grasping
> some basics of interprocess communication.

well, hmm, yes ... its indeed quite a difference between reading about
and learning this stuff and putting it into practice.

> You have some other program running in another process, not started by
> emacs and you want to communicate with it. A critical factor in such
> communication will be knowing how that other program is set up to
> communicate. 

Simply assume for the moment that the other lisp knows how to
communicate in a similar way like Emacs Lisp, thus many of the standard
UNP mechanisms are available (pipes, sockets, tcp/http...)

> Some programs are developed to have standard communication ports and
> protocols, like HTTP. Unix/Linux supports signals (kill) which a
> program may be set up accept and respond appropriately toward. A
> program may support TCP/IP or Unix sockets. A program may read and
> write files. You might have shared memory space or semaphores. There
> are dozens of different mechanisms. Emacs supports some of them out of
> the box. It might be that you can extend emacs by writing code to
> support other mechanisms. Another alternative is for emacs to
> communicate with a subprocess it creates running a program designed to
> communicate with the other process. However, what does the other
> program support? This is the question you need to answer. We can't
> make up an answer for you.

I figured out now that, in my special case, talking from Emacs via url
requests to the running http-server of the other Lisp works out just
fine, so my original problem is more or less solved. 

OTOH, this topic has become quite interesting, and I'm still curious
about my original question: how to use all these UNP mechanisms from
Emacs Lisp when the other (Lisp) process is not a subprocess but already
running (with a given PID). 

> As an analogy, if you and I wish to speak, we may need to speak face
> to face. If we don't speak the same language we have trouble. Maybe we
> can talk on the telephone, but if you don't have a telephone, we are
> not going to speak that way. Communication takes appropriate
> coordination for the sender and receiver.

Aurelien posted an example how to use plain TCP, I figured out how to
use HTTP, so there are possibilities. But wrt to pipes and sockets,
e.g., I still would not know how to address that other running (Lisp)
process with given PID from Emacs although both Lisp dialects are
definitely able to communicate via pipes and sockets.

This case is simply not covered in the manuals/books, its always about
(new) subprocesses started under the control of one of the two Lisps.
And from what I learnt from this discussion, it does not seem possible,
except sending signals with 'kill. 

Assume there are 2 otherLisp processes up and running and 2 Emacs
processes, and you want to communicate from otherLisp with PID 5555 to
Emacs with PID 6666.

Now, if you don't care about the specific process you talk to, just the
program, you could simply use

| (in (list Emacs <<ARGS>>))


| (call 'Emacs <<ARGS>>)

from otherLisp to talk to Emacs, or use `call-process' or `start-process'
from Emacs to talk to otherLisp. 

But from an Emacs Lisp program, how would you establish pipe or socket
communication to that one specific otherLisp process with PID 5555
already running, and not under control of Emacs process with PID 6666?
>From all I heard, all you can do is send 'kill signals to that process. 

> Kevin Buchs | Senior Engineer | SPPDG | 507-538-5459 |
> Mayo Clinic | 200 First Street SW | Rochester, MN 55905 |
> -----Original Message-----
>> How would you communicate with the external process, from any other
>> program?
> I don't know, and I interpreted the responses so far to my post as "it
> is impossible, only 'kill' can access the running external process with
> given PID" - but kill sends signals, no command-strings or so. 
> So when suggestions arrive like 'use plain socket communication' I'm
> still curious if there is a 'magic hack' to achieve that, given that the
> external process is NO Emacs subprocess and already running.


reply via email to

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