X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=OPxuQtYoTAad9fmv EZTXBft6sHEPWIAVoHHRMg5Z6etBQ6lz3qVALQc1KoGAvgc9/Sr+ndQUi8aAMeWh H72KKSiEulV9mOMVt0r2g+yxXzKQcSPiv5rQ9gzjJyDJk4ZZ4kHdIR2HDfsj0G2K cllLVVGwdSZi3j2JleEwGnLCN88= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=t3+qM8uxsVFMKsuFcJNr3Z bnUbE=; b=F6pX8CX4mg3TVeLR9XNTbbV8e0BW1OL/z4r7lCBSw/eBt5kPI+3WwM RdZnmyEMTmJlo3UiBDcQ9XA2eBcY3LlehE0aDcmhQ2mQbKFYnmyQAGe9xYiOw/ob qZTfDOqNfaJUvL44aQZTbjl0yjDBy6zGaJD+Hka+zzeZRxshKsBns= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*M:gmx, H*r:ip*192.168.0.5, cristian, Cristian X-HELO: mout.gmx.net Subject: Re: windows exit codes truncated to 1 Byte To: cygwin AT cygwin DOT com References: <1233154500 DOT 205789 DOT 1459429282664 DOT JavaMail DOT yahoo DOT ref AT mail DOT yahoo DOT com> <1233154500 DOT 205789 DOT 1459429282664 DOT JavaMail DOT yahoo AT mail DOT yahoo DOT com> From: =?UTF-8?Q?Bj=c3=b6rn_Stabel?= Message-ID: <56FD268D.4060904@gmx.de> Date: Thu, 31 Mar 2016 15:30:53 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1233154500.205789.1459429282664.JavaMail.yahoo@mail.yahoo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-UI-Out-Filterresults: notjunk:1;V01:K0:3BbnMZbZP94=:tRvbdQsE7LCcfoac6DBAM2 vnujV0r1FT6LteHXjtXqp8cRVuDQejL30PQ6Cn1Nff+Ft7wQFwmxT20/oGMYR+68gGQHoNl91 7o0V4xIa6HHZJtDg4bgOhThirXQjt6Bzgs8stYS6RkvkTHN42anAE8zBdlslA+yetyLLeDEss fsTbL1HbcYJulaG67SH3ywTDMgCs07g+wRGqTUiu1UBlly7GMawcbMbQx8SVSC2zuz8aOKfpD +kXrJuidqTd67ar9JXaYuoIMJWJGgDQUa7agbBfrbBkJll79aVw/LSCHNUHFrznIH88K+oS0A 3IV8t3tu7cOdKXpoI0Ou8TnDfyaJp3TPkFa63V7HgT9UISgY5M/vAZG+jyyj8S0BiSX8ubrAg 8TH1qgmj9bwWyGph2d+CH4sSlj9G08LceX76uOx++gaAUTEmPCkg2uofGHK0yLANvNVXDVJHD jBZPdyH+cUn4xFo1lIh0QvGc8BheOv0G0DDpVC0UCbtgkdIGCIucIOO3JIoUrbeaI/cuXdeZG 7r21Tw02XIghyo3d+OXndwBfDgfYQMItaeKlYQceILagLK9dZWO/mpj1KAxkI59zX8ihM9q4e iZ/0Io7fdCgNSOq33n+OcTXaBhVuylO92/PNGKNj3TIWSqPbMkbJgldLpMcyBcXk1MSZS8eDb dcZbbN0wu+hzzxZzSRocPSUK0kR6zpF5HbQgBffA+bdVH2AftRdV6WM7GTCA+T62C+PbDaNJW H9osiwv5jBjNgyrU8ynm+X7jnzBgq9ScTqovUGEpwYvECmel0tfPA1WcUFiaKj6Fk4H+1aws7 peGKNik X-IsSubscribed: yes Am 31.03.2016 um 15:01 schrieb Cristian: > I noted that exit codes returned by CMD and other apps (msiexec) are truncated to 1 byte (0 .. 255). > > Steps to reproduce: > > 1) Create a batch with this content: > $ cat ./test.bat > @echo off > rem ==================== > echo Test exit code 266 > exit /B 266 > rem ==================== > > 2) run the batch file: > $ ./test.bat > Test exit code 266 > > 3) check exit code > $ echo $? > 10 > > > I would expect 266 but I got 10 instead. I checked for other codes and the result is the same. > Windows exit codes are represented using 32 bits, so is this limitation intentional? POSIX specifies that the lower 8 bits of the exit status be made available to the caller of wait/waitpid: http://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html "WEXITSTATUS(stat_val) - If the value of WIFEXITED(stat_val) is non-zero, this macro evaluates to the low-order 8 bits of the status argument that the child process passed to _exit() or exit(), or the value the child process returned from main()." Maybe there's another way to get the entire status value, but this looks like a POSIX limitation to me. Cygwin is conformant here. The more interesting problem is what happens if you do "exit /B 256" in your batch. In that case, bash would show a return status of zero. That's what the WIFEXITED macro is used for. Not sure how you'd get that from bash, though. > > > Best regards, > Cristi > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple