From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?=C3=93scar?= Fuentes Newsgroups: gmane.emacs.bugs Subject: bug#6430: Emacs WINDOWS truncates exit status of processes to 8 bits Date: Wed, 15 Jun 2016 19:36:14 +0200 Message-ID: <87a8imjqwh.fsf@wanadoo.es> References: <1310.80.58.205.52.1276622459.squirrel@correo.ozu.es> <831t3zg7or.fsf@gnu.org> <83d1njdvk9.fsf@gnu.org> <87mvmmk52b.fsf@wanadoo.es> <8337oeebr0.fsf@gnu.org> <87inxajxed.fsf@wanadoo.es> <83y466cvfs.fsf@gnu.org> <87eg7yjrwu.fsf@wanadoo.es> <83shwecq84.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466012254 745 80.91.229.3 (15 Jun 2016 17:37:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Jun 2016 17:37:34 +0000 (UTC) Cc: macross84@ozu.es, 6430@debbugs.gnu.org, npostavs@users.sourceforge.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 15 19:37:23 2016 Return-path: Envelope-to: geb-bug-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 1bDEkg-0005ff-3a for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Jun 2016 19:37:18 +0200 Original-Received: from localhost ([::1]:44047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDEkf-0006Cn-CJ for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Jun 2016 13:37:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDEkW-0006AM-MZ for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2016 13:37:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDEkQ-0002JZ-NG for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2016 13:37:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDEkQ-0002JV-Jd for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2016 13:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bDEkQ-0003J3-AD for bug-gnu-emacs@gnu.org; Wed, 15 Jun 2016 13:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Jun 2016 17:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6430 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 6430-submit@debbugs.gnu.org id=B6430.146601218612664 (code B ref 6430); Wed, 15 Jun 2016 17:37:02 +0000 Original-Received: (at 6430) by debbugs.gnu.org; 15 Jun 2016 17:36:26 +0000 Original-Received: from localhost ([127.0.0.1]:42560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDEjp-0003IB-S3 for submit@debbugs.gnu.org; Wed, 15 Jun 2016 13:36:26 -0400 Original-Received: from smtp08.acens.net ([86.109.99.132]:33640 helo=smtp.movistar.es) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDEjn-0003Ht-1i for 6430@debbugs.gnu.org; Wed, 15 Jun 2016 13:36:24 -0400 X-CTCH-RefID: str=0001.0A0B0206.57619210.0021, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown Original-Received: from qcore (217.125.182.141) by smtp.movistar.es (8.6.122.03) (authenticated as 981711563$telefonica.net) id 5746319D012A29F0; Wed, 15 Jun 2016 17:36:16 +0000 In-Reply-To: <83shwecq84.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 15 Jun 2016 20:32:43 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:119592 Archived-At: Eli Zaretskii writes: >> From: =C3=93scar Fuentes >> Cc: npostavs@users.sourceforge.net, macross84@ozu.es, 6430@debbugs.gnu= .org >> Date: Wed, 15 Jun 2016 19:14:25 +0200 >>=20 >> Eli Zaretskii writes: >>=20 >> >> > GetLastError has nothing to do with this, because it's not an API t= hat >> >> > fails, it's a program that exits with some arbitrary exit code. >> >>=20 >> >> if( ! CreateProcess(....) ) { >> >> DWORD ec =3D GetLastError(); >> >> // do some cleanup >> >> ExitProcess(ec); >> >> } >> > >> > That's not how Emacs does that, see waitpid and its callers. >>=20 >> Once again, we are miscommunicating. AFAIU this is about Emacs calling a >> process foo which returns an exit code larger than 255, but Emacs only >> reports the lower 8 bits to the Elisp function that started the process. >>=20 >> In w32proc.c waitpid: >>=20 >> if (!GetExitCodeProcess (wait_hnd[active], &retval)) >> ... >> retval <<=3D 8; >>=20 >> Windows applications make use of the full 32 bits of the return code. >> With Emacs it is impossible to know those larger-than-255 exit codes. > > But not because of the code you cite: the 8-bit left shift just means > we can report 24 bits out of 32. And all of that is completely > unrelated to GetLastError, because errors in starting the subprocess > are not reported via waitpid. GetLastError on my example was on the *called* process, not on Emacs. > Once again, if this is important (I don't think so), we can redefine > WEXITSTATUS etc. macros to keep all the 32 bits of the exit status > (actually, the top 2 bits are reserved, so only 30 bits can be used). When using --with-wide-int (or when running on Windows 64bits) we have the full 32 bits, right?