From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juan =?utf-8?Q?Jos=C3=A9_Garc=C3=ADa-Ripoll?= Newsgroups: gmane.emacs.devel Subject: Problems with call-process (= identifying run-python issues) Date: Tue, 18 Aug 2020 15:36:23 +0200 Message-ID: <86h7t0nkiw.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="31323"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (windows-nt) To: emacs-devel@gnu.org Cancel-Lock: sha1:4f5iXzQwFIdoutzIOp+tK7itxB0= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 18 15:37:10 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 1k81na-00082p-2x for ged-emacs-devel@m.gmane-mx.org; Tue, 18 Aug 2020 15:37:10 +0200 Original-Received: from localhost ([::1]:43966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k81nZ-0007nE-63 for ged-emacs-devel@m.gmane-mx.org; Tue, 18 Aug 2020 09:37:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k81mz-0007KL-FI for emacs-devel@gnu.org; Tue, 18 Aug 2020 09:36:33 -0400 Original-Received: from static.214.254.202.116.clients.your-server.de ([116.202.254.214]:37916 helo=ciao.gmane.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k81my-0002vJ-03 for emacs-devel@gnu.org; Tue, 18 Aug 2020 09:36:33 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1k81mv-0007H9-8c for emacs-devel@gnu.org; Tue, 18 Aug 2020 15:36:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/18 09:36:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 20 X-Spam_score: 2.0 X-Spam_bar: ++ X-Spam_report: (2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:253943 Archived-At: Hi, I am running into a weird issue in Windows 10, both with Emacs 27 and Emacs 26.3. It all boils down to whether Emacs is invoked from the command line or not. In one case, subprocesses get their input properly redirected, in other cases not. All tests are done with plain vanilla Emacs, using core libraries (no programming mode). My test files are below. Essentially, the file test.el is trying to imitate what python.el uses to call a python process, but instead of that, it uses a simple copycat script that copies the input stream to the output stream. - If I launch the program from the command line, as in C:\Users\juanj\scoop\apps\emacs-27.1\bin\runemacs.exe -Q --load c:\Users\juanj\Downloads\test.el everything goes fine. In the *Messages* buffer I see this output "Output: \"import sys ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)] ps_json = '\\\\\\\\n[\\\\\\\"%s\\\\\\\", \\\\\\\"%s\\\\\\\", \\\\\\\"%s\\\\\\\"]\\\\\\\\n' % tuple(ps) print (ps_json) sys.exit(0) \"" - If I create a shortcut for runemacs, adding "-Q --load test.el" as arguments, then process-file outputs nothing. The *Messages* buffer shows "Output: \"\"" - If I type #+R (Windows key + R) and enter directly the command line "C:\Users\juanj\scoop\apps\emacs-27.1\bin\runemacs -Q --load c:\Users\juanj\Downloads\test.el" the script also fails and produces the wrong output. There are no error messages. The script gets invoked (you may add a line "echo foo" to chain.cmd and see that it is output), but it does not get the redirected input. ---foo---(test file 1, saved as c:\Users\juanj\Downloads\foo) import sys ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)] ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps) print (ps_json) sys.exit(0) --test.el---(test file 2, saved as c:\Users\juanj\Downloads\test.el) (with-current-buffer "*Messages*" (with-temp-buffer (call-process "c:/Users/juanj/Downloads/chain.cmd" ;conda_python.cmd" "c:/Users/juanj/Downloads/foo" '(t nil) nil "-i") (print (format "Output:\n%S" (buffer-string))) )) ---chain.cmd---(test file 2, saved as c:\Users\juanj\Downloads\chain.cmd) @echo off rem copies lines from the input until it is empty :begin set /p line= || goto :end echo %line% goto :begin :end -- Juan José García Ripoll http://juanjose.garciaripoll.com http://quinfog.hbar.es