From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 9D9963858D35 for ; Wed, 18 Jan 2023 20:47:14 +0000 (GMT) Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1pIFKz-0003Dl-2C for gcc-patches@gcc.gnu.org; Wed, 18 Jan 2023 21:47:13 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: Re: [Patch] libfortran: Fix execute_command_line for Windows Date: Wed, 18 Jan 2023 21:47:06 +0100 Message-ID: References: <0b95e5f1-142e-e13a-7d77-272073e25c2a@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US In-Reply-To: <0b95e5f1-142e-e13a-7d77-272073e25c2a@codesourcery.com> Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20230118204706.OIn0M94r7DV3FK9NEV1LjeCapjsDOwH5QR9F04et4yE@z> Hi Tobias, Am 18.01.23 um 16:42 schrieb Tobias Burnus: > Reported by nightstrike, who also tested this patch. > > On Windows, we call system() which works as described at > https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/system-wsystem?view=msvc-170 > > Namely, it only fails with "-1" if the command interpreter > could not be started. Otherwise, it has the return value. > (Same on Linux.) On POSIX systems, 'sh' calls exit(127) or > _exit(127) if it cannot execute the program of the passed string, > as documented. Cf. https://www.unix.com/man-page/posix/3p/system/ > > Thus, the question is what happens on Windows. Our experiments, several > webpages (like stackoverflow) and the source code of WINE for cmd.exe > indicate > that Windows returns 9009 in that case. See for instance > https://github.com/wine-mirror/wine/blob/master/programs/cmd/wcmdmain.c#L1262-L1269 > > Thus, we now do likewise. The code is for MINGW; Cygwin does not set > that that > var and is likely to use return values closer to POSIX. I don't use Windows, but this LGTM. > OK for mainline? Yes, and thanks for the patch! Harald > > Tobias > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, > 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: > Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; > Registergericht München, HRB 106955