From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: Re: How to communicate with a running external process with given PID? Date: Mon, 22 Jul 2013 10:06:26 +0200 Message-ID: <877ggjyq65.fsf@gmail.com> References: <87mwph7bav.fsf@informatimago.com> <87ip05726h.fsf@informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1374480429 31631 80.91.229.3 (22 Jul 2013 08:07:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Jul 2013 08:07:09 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 22 10:07:11 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 1V1B9A-0000j7-Mt for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Jul 2013 10:07:08 +0200 Original-Received: from localhost ([::1]:36161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1B99-0001Pb-Vs for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Jul 2013 04:07:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1B8u-0001K8-Ad for help-gnu-emacs@gnu.org; Mon, 22 Jul 2013 04:06:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1B8s-0001U4-Hw for help-gnu-emacs@gnu.org; Mon, 22 Jul 2013 04:06:52 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:53058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1B8s-0001To-96 for help-gnu-emacs@gnu.org; Mon, 22 Jul 2013 04:06:50 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V1B8l-0000Gt-AI for help-gnu-emacs@gnu.org; Mon, 22 Jul 2013 10:06:43 +0200 Original-Received: from e178189097.adsl.alicedsl.de ([85.178.189.97]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Jul 2013 10:06:43 +0200 Original-Received: from tjolitz by e178189097.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Jul 2013 10:06:43 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 76 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178189097.adsl.alicedsl.de User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:EwDgo+trJnrqSetld2Iee2ROgGM= 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:92307 Archived-At: "Pascal J. Bourguignon" writes: > Thorsten Jolitz writes: > >> "Pascal J. Bourguignon" writes: >> >>> Thorsten Jolitz writes: >>> >>>> Hi List, >>>> >>>> say I want to call another program (more exactly, another Lisp >>>> program that is not Emacs Lisp) from an Emacs Lisp program. >> >> [..snip..] >> >>>> I could run a server in the external lisp program and use a >>>> network-connection-object to send http-requests (e.g. with the help >>>> of emacs-request.el) via TCP - but that seems to be total overkill >>>> for my requirements. >> >>> Ok, I'll bit the bullet: the only communication channel available to >>> you, a-priori, knowing only the process ID, is the kill(2) syscall. >>> And you're lucky, you can send more than one bit of information with >>> each kill call! >> >> Yes, I should read UNP, but actually I read quite a lot of stuff >> about this topic, but reading about it and starting to use it is not >> the same thing. And I did not know that 'kill is so useful and >> universal, only used it for its core task so far. >> >> But in the light of your answer I think I go for the HTTP >> client/server solution, expecially since the server stuff is all >> there anyway. >> >> Thanks for the tips. > > Ok, that's a starting point. > > The thing is that you cannot talk to a process that's not ready to > talk, with some protocol. > > The summary of unp, is that there are various IPC (Inter Process > Communication) mechanisms: > > - signals (kill(2), signal(2)), - semaphores (semctl, semget, semop, > semtimedop) - messages (msgctl, msgget, msgrct, msgsnd) - shared > memory (shmat, shmctl, shmdt, shmget) - sockets (listen, accept, read, > write, close) - pipes (pipe, fork, read, write, close) - named pipes > (open, read, write close) - files (open, read, write close) > > and the only mechanism that does something by default in the receiver > is signals (cf. signal(2) and signal(7)). Now, of course, most signals > are ignored, and a few others only kill the receiving process by > default (hence the name of kill(2)), which is not much of a > communication, but that's something, contrarily to the other > mechanisms, when the receiving process doesn't do anything about them. > > > But since you're saying that the process includes a HTTP server, that > means you can open a TCP socket on the port it's listening to, and you > can communicate with the HTTP protocol. > > 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 Not that I have not heard about this UNP stuff, I probably hoped that Emacs has some kind of 'magic' functionality for arranging things behind the scene ... But HTTP is a good and actually not that difficult solution in this case. Thanks for the links. -- cheers, Thorsten