From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sean McAfee Newsgroups: gmane.emacs.help Subject: Confused about sending text to a subprocess Date: Fri, 02 Apr 2010 17:29:53 -0700 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1273002273 24305 80.91.229.12 (4 May 2010 19:44:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 4 May 2010 19:44:33 +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 May 04 21:44:32 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O9O2g-0001EF-I0 for geh-help-gnu-emacs@m.gmane.org; Tue, 04 May 2010 21:44:30 +0200 Original-Received: from localhost ([127.0.0.1]:50864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9O2f-00020M-OF for geh-help-gnu-emacs@m.gmane.org; Tue, 04 May 2010 15:44:29 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Fri, 02 Apr 2010 19:29:54 -0500 Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) Cancel-Lock: sha1:YFjSttyVlEx9SVOg0ir7OYgbJ9c= Original-Lines: 50 Original-X-Trace: sv3-CFJwNtp9R4iSeIeAri8A1UFhL1HDpy3B/XDaN+RH0I1eTErw2KlVz7ZGhEYoLnvrXiMEpUTU854hyJZ!oHXBHrniBBrLRK6ojsWeMgE5iNqWGQ+zJWVQQhfMd5XPf1fBwDuHnI48 Original-X-Complaints-To: www.supernews.com/docs/abuse.html X-DMCA-Complaints-To: www.supernews.com/docs/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Original-Xref: usenet.stanford.edu gnu.emacs.help:177631 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:73104 Archived-At: So I have this little Perl script: #!/usr/bin/perl open X, ">/home/me/ABCXYZ" or die "$!\n"; print X "Start ", scalar localtime, "\n"; print X $_ while ; print X "\nEnd\n"; I invoke it from Emacs like this: (let ((proc (start-process "x" nil "/path/to/perl/script"))) (process-send-string proc "foo\n") (process-send-eof proc)) It works as I expect. But if I leave off that newline: (process-send-string proc "foo") ...then the subprocess does not exit. It continues to appear in the list returned by process-list, and its status, as reported by process-status, is "run". No output appears in that Perl script's output file, I suppose because it's being buffered and the script is still stuck in that loop on STDIN. In most languages I might write something like this in, I would indicate an end to the output to the subprocess by simply calling close() on a stream that's connected to the subprocess's pipe. I had supposed that that's what Emacs's process-send-eof does, but I don't think that can be correct. Actually, the section of the Emacs Lisp manual entitled "Sending Input to Processes" is rather confusing in this regard; it states: >Some operating systems have limited space for buffered input in a >PTY. On these systems, Emacs sends an EOF periodically amidst the other >characters, to force them through. For most programs, these EOFs do no >harm. I don't even know what it means to send an EOF amidst other characters. I thought EOF was the special out-of-band code (usually -1) that getchar(3) et al. return to indicate that a stream has been closed. Maybe I'm missing something obvious, but I've looked all over the "Processes" section of the manual, and I haven't found any function that says it simply closes the connection to the subprocess. There are several that send signals to the subprocess, but I don't want to do that. What's the right way to indicate that one is totally finished sending data to a subprocess, and that the connection should be completely closed?