From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: How to communicate with a running external process with Date: Tue, 23 Jul 2013 21:09:01 +0200 Organization: Informatimago Message-ID: <87mwpd3xgy.fsf@informatimago.com> References: <7DEC2F40B9E0874681480168A47FD3C11AF1E5E6@MSGPEXCEI32B.mfad.mfroot.org> <87txjlr9js.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1374606589 22174 80.91.229.3 (23 Jul 2013 19:09:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Jul 2013 19:09:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 23 21:09:52 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V1hxz-0002Ot-Js for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Jul 2013 21:09:47 +0200 Original-Received: from localhost ([::1]:47883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1hxz-0005rh-4X for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Jul 2013 15:09:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1hxm-0005rL-Lz for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 15:09:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1hxk-00020J-SV for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 15:09:34 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:34143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1hxk-000202-If for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 15:09:32 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V1hxh-00024g-Po for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 21:09:29 +0200 Original-Received: from 90.24.241.80 ([90.24.241.80]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Jul 2013 21:09:29 +0200 Original-Received: from pjb by 90.24.241.80 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Jul 2013 21:09:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 89 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 90.24.241.80 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:MTBiYjkyN2UxYjAzMDU2NjE4NDhiYzhiNDlkNDgyYmM1NjQzNDhjNA== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92349 Archived-At: Thorsten Jolitz writes: > 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). You started specifying only another "process" PID, but now you're saying it's a "Lisp" process. What does that mean? If the PID is fixed, then the process is fixed, and therefore the program of this process is fixed (even if you have the sources), the process owner is fixed, etc, (unless some special cases where the process is programmed to change those parameters, eg. a shell program or an interpreter or indeed, a lisp implementation). But you are not saying what the program of the other process is. The only thing you told us about it is that it has a HTTP server. But by what you're saying later, I've got the impression this HTTP server is not actually running, is not actually listening to a TCP/IP port. If it is, why don't you tell us that you know what port it's listening to, and how should you use emacs to connect to that port and perform the HTTP requests you need? It is trivial to obtain the map of listening ports and PID: sudo netstat -tnpl (sudo is optional, it's to get the name of the program running in the processes you don't own). Now, you said lisp, but since you're building a history of imprecise language, perhaps we should assume you mean Common Lisp? There's a protocol that has been defined specifically to communicate between an emacs and a Common Lisp process, with which a whole IDE has been built in emacs, named slime (the backend, the library that implements that protocol on the Common Lisp side is called swank (as is called the protocol)). With slime/swank you can connect a CL process with an emacs, and from emacs, send CL expressions to evaluate to the CL process and receive back results, and debug and develop CL programs. But if you specifically meant that, you could easily read the manual of slime which indicates how to create from emacs a new CL inferior process running swank, and how to connect from emacs to an existing CL process that runs a SWANK server (therefore that is listening to a specific port, just like a HTTP server). > 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. As I told you, the only communication channels that use the PID to identify the end point, is made of kill(2) and signal(2). And as I told you, the receiver has better be ready to get the signal, otherwise the default behavior for most signals is to kill the process. Which is as good a reaction to a message as anything else. So, for example, to send the USR1 message, I mean, the USR1 signal to the process 5555 from emacs, you could do: (shell-command "kill -USR1 5555") > 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. That's because you don't read the whole messages. I've already mentionned the emacs manual chapters you have to read to know that: > In emacs, you can do that with "network processes": > http://www.gnu.org/software/emacs/manual/html_node/elisp/Network-Processes.html > http://www.gnu.org/software/emacs/manual/html_node/elisp/Processes.html -- __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