From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Problems with call-process (= identifying run-python issues) Date: Wed, 19 Aug 2020 17:41:02 +0300 Message-ID: <83a6yqem0x.fsf@gnu.org> References: <86h7t0nkiw.fsf@csic.es> <831rk4ezbu.fsf@gnu.org> <83wo1vexck.fsf@gnu.org> <865z9fggec.fsf@csic.es> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25439"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Juan =?utf-8?Q?Jos=C3=A9_Garc=C3=ADa-Ripoll?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 19 16:45:09 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k8PKu-0006SO-TO for ged-emacs-devel@m.gmane-mx.org; Wed, 19 Aug 2020 16:45:08 +0200 Original-Received: from localhost ([::1]:41892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8PKt-0001EG-P7 for ged-emacs-devel@m.gmane-mx.org; Wed, 19 Aug 2020 10:45:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8PH7-0004Vd-GA for emacs-devel@gnu.org; Wed, 19 Aug 2020 10:41:13 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49349) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8PH7-0002eg-6D; Wed, 19 Aug 2020 10:41:13 -0400 Original-Received: from [176.228.60.248] (port=1325 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1k8PH6-0007DU-It; Wed, 19 Aug 2020 10:41:13 -0400 In-Reply-To: <865z9fggec.fsf@csic.es> (juanjose.garciaripoll@gmail.com) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:254013 Archived-At: > From: Juan José García-Ripoll > > Date: Wed, 19 Aug 2020 10:59:39 +0200 > > Ok, let me please explain the problem: I want to run a process that gets > its input from a file, while Emacs collects its output. This is standard > working in many programming modes. For instance, it is the way > run-python calls python to find out the prompt. > > I am finding that when I launch Emacs from the windowing environment > (e.g. shortcuts, Start menu, Windows key + R, explorer), Emacs does not > redirect the input of the subprocess properly. If I launch the Emacs > from the command line, the subprocess works as expected. > > To reproduce this I have created a minimal example: > > - A bogus input file (foo), that is going to be the redirected input of our > program > > - A script, chain.cmd that copies all input to its output, line by > line. This is going to be the subprocess. Unfortunately, Windows does > not have a 'cat' command, which is why I did it this way. > > - An elisp file (test.el) that launches the process with the redirected > input and collects the output > > This example can be ran in three different ways: > > - Invoking runemacs.exe -Q --load test.el from the command line > - Running the same command with Windows key + R > - Creating a shortcut that does the same. > > All ingredients are needed, because we need a reproducible program, an > input file and some sophisticated commands that use Emacs' > call-process. However, it is *not* complicated at all and everything is > pretty standard. OK, thanks. I have now tried this on 2 different Windows systems, one of them Windows 10, and I cannot reproduce what you describe. No matter how I invoke Emacs, I get the expected output in the buffer: the contents of the file passed as standard input to the subprocess. So I think either this is due to some local configuration issue on your system, or there's some part of the reproduction recipe that you omitted. > One consequence of this problem is that run-python does not work as > expected (Emacs fails to find the prompt), but as I try to show, this is > not due to Python. Working with Python on Windows has its quirks, because you need to make sure Python uses unbuffered writes to its standard output. That is why I wanted to be sure Python is not involved here.