all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to communicate with a running external process with
Date: Tue, 23 Jul 2013 09:59:35 +0200	[thread overview]
Message-ID: <87txjlr9js.fsf@gmail.com> (raw)
In-Reply-To: 7DEC2F40B9E0874681480168A47FD3C11AF1E5E6@MSGPEXCEI32B.mfad.mfroot.org

"Buchs, Kevin J." <buchs.kevin@mayo.edu> 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>>))
`---------------------------

or 

,-----------------------
| (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 | buchs.kevin@mayo.edu
> Mayo Clinic | 200 First Street SW | Rochester, MN 55905 | http://www.mayo.edu
>
> -----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.

-- 
cheers,
Thorsten




  reply	other threads:[~2013-07-23  7:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 15:27 How to communicate with a running external process with Buchs, Kevin J.
2013-07-23  7:59 ` Thorsten Jolitz [this message]
2013-07-23  8:22   ` Yuri Khan
2013-07-23  9:30     ` Thorsten Jolitz
2013-07-23 19:09   ` Pascal J. Bourguignon
2013-07-23 20:13     ` Thorsten Jolitz
2013-07-23 23:06       ` Pascal J. Bourguignon
2013-07-24  6:34         ` Thorsten Jolitz
     [not found]   ` <mailman.1659.1374606578.12400.help-gnu-emacs@gnu.org>
2013-07-23 19:12     ` Pascal J. Bourguignon
2013-07-23 20:15       ` Thorsten Jolitz
     [not found] ` <mailman.1619.1374566396.12400.help-gnu-emacs@gnu.org>
2013-07-23 14:43   ` Barry Margolin

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=87txjlr9js.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --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.