delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/06/26/12:27:47

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 590FB3856DED
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1656260866;
bh=BjD1LPTuJ3FO7DWvIt1jVgtgwW7NuQ4diBVK/2AG57Y=;
h=To:Subject:Date:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=kf03Nisj6hnf0W/91/6CcVY3kad+In8KDurvF1JLXxzmByoBaISBAtp84nhumR7P7
1X5mWv9M1nkKFgEKu/S0t6joZ3AUxDMRmQwxZFsc/dq8T6JlMankap6eDMoxwH3hNx
TYY1zny09x7bEdUvWeWVpERcEdaf4lp47ykjUOyk=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6BB783858C56
X-SBRS-Extended: Low
X-IronPortListener: ces-out
X-IronPort-AV: E=Sophos;i="5.92,224,1650945600"; d="scan'208";a="249317502"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=DkMVatAGUAQeENQrFAD52+tYvENsADBCYyC7h6hVMSiMfcjqZk1TNQKNtgUV1YZaIhn/PfJRPmDlK4pUIhFcdCA1OCgD2InTpTt84NdshWQgMq0YWZZid7sXKmPK5r8Y1TIZxecNueeabOaUU6e9Mt7VEZFaxy15Pdd2yAbfLL+2dalcMSoG7c+ExQLSk+WnOE0ZFU1IdkIE7BLWMLzt5C3qdY0zXLw34zOt8tcPa39W/7GP/WKFSk+NAsYTvjEKloENuq8sy0NRsTvHYc0qfSBDic71kjATvoHNK3RbKhKMwecS8w6Sfui7U84QPkID33ontg43Ad+nRPO66iycow==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=c3dUbMDXl7BWHElkSYAIAgPUbkvVcUSsOpIxFLj2kPs=;
b=Pi8nGqLd7CLGPgspOKC6NqdHp+pnp/9u4tq1/VzT96TmRK1I6/rb00d3blD6bpAfANlYm+efaqn5docZ2vq90itI3cwPCTenBH6vS9b+jlNWuOhRXp+q5R3P9uwJZuSZSuTRfp9Bpvi9S/EV82VVCqwwppe/QWL1JOt09Qv0XurzeCKVpXfy6agVSL9DxJhg8HX56ez9p8vnLKQxcX0/Pxjr0jDMUCNqsTjYTBaAw+ENj/6dHQp5KpF0TxMxCegt+cqValAKSPnAtPx/EIF8ykcCaLlfytVkTLQWR+8OdZXLNgWV7dO/kNg/DbURhKNwGuvnHLF7pqxqCL9KjTujLQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=ncbi.nlm.nih.gov; dmarc=pass action=none
header.from=ncbi.nlm.nih.gov; dkim=pass header.d=ncbi.nlm.nih.gov; arc=none
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: RE: Cygwin's execlp() does not work with an empty $PATH element
Thread-Topic: Cygwin's execlp() does not work with an empty $PATH element
Thread-Index: AdiJbrs+rXZuHXNaTrCqY66Eq3KrXAACh9EQ
Date: Sun, 26 Jun 2022 16:26:35 +0000
Message-ID: <DM8PR09MB7095ABBBD60E7A36C0303689A5B69@DM8PR09MB7095.namprd09.prod.outlook.com>
References: <DM8PR09MB7095965E449CC03DEE772338A5B69 AT DM8PR09MB7095 DOT namprd09 DOT prod DOT outlook DOT com>
In-Reply-To: <DM8PR09MB7095965E449CC03DEE772338A5B69@DM8PR09MB7095.namprd09.prod.outlook.com>
Accept-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 189c0f8e-605c-403e-d68d-08da5790a32c
x-ms-traffictypediagnostic: DM6PR09MB5704:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: ZmKdIZUhNxn6ofoG+HZRFTCd8jfcf26Qti88/SGZ7D8v3lG2OajUlB7pNNX/NCs+P9EM+A8Sk1QLCbk7qNoa8Hcwwyikzk66bYg4dlJWRHR3KtERVRJsGe6doQG7NlANOsoQA1I+igZpRaVuoAMnX7agaTlEeOJ9GDiPSa70ZaKSA2TZ7jpFY7Z+8WerjnUQ16sdK5diNS4Ts3Qg76ZA+Sk0xB7t4XAaT0dMAM4jJ5SlqwG+Operh73ljk3SKLbx6yi6hlW6epr2fK5qW2WXiVROU02zIAUr1eZO620fPh/pfYjuTA17ypqu+aFKYwPpHCl4LeyJizoifF2Y12AqjKaY2if9v+NqDGZd+qriJV6zcLe/f7IbfNjWMZvpPv8smM2NaTNhqwI1PVqtl3IrJUkJG7i6OPPwTkHu97Sqv2a9Nw4n4N+FhpQqfzpAMCiLCWIza8nk5xgJVdLDJqtyxFPtbkXBA1PUbe59Z5ptQ7loy8o8tUe6LgojNFKvQOPqkpJIlFmETdfEedkdJjjgGIIGXuSGYq8QSwFzUwwFoFusHgJSqSmCYhF2VfGuOM0KsMMo8b2yxs6Iz2sQVAGVpk1wy+XOQVo1catuLz9y1fwtSbLct62R3Ce3jWEDg2XQBTMG/9ZauOjXIxI5AV7jYnfcW3NooMtJdRAGz3XPTq+8myFe3cb0KRGP9+kprm0eXnefURAGTrGmXdOesiLbd6TOOzKCrp/MPOnA1UAk1Bbv9iVuPUD6VWuwxq2KYp2wTSg0+utNVLMSG5+4xM5er0n08XHELUZOG0jRPNGo6FthFFsJWBoYr7/SiIvNGDG+UZ/eiiYkcq3Rl38kKAhat7Kbsa21J8WXg44Hnk7OmiiRnGOc6mt6nl6ED2VuiX9M
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:DM8PR09MB7095.namprd09.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230016)(4636009)(366004)(64756008)(66946007)(7696005)(66556008)(66446008)(8676002)(66476007)(2940100002)(76116006)(498600001)(55016003)(8936002)(26005)(52536014)(71200400001)(38100700002)(966005)(38070700005)(6506007)(9686003)(86362001)(53546011)(33656002)(122000001)(5660300002)(45080400002)(6916009)(186003)(83380400001)(2906002)(21314003)(491001);
DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?DXlge5kyh0pi2HyvMA6OQGugdK4hVPWt3CotB4vmaFrQ9W2ZUNR/GM0Fti1Y?=
=?us-ascii?Q?hpKS+BaT6VXzMi51A5JRqD1NGnA4gSpQlMh5onsp+iIOyV+1rwY5O6vMi8pC?=
=?us-ascii?Q?QrxiHn3KBo6U6BBIjOwGz8ZUTBheIXg4H193tt42hQ5JsCKURgowVtmi6lHn?=
=?us-ascii?Q?IVbZjbfPEFRcjJsxqb+OP1t+Ja/1sEJcF79E98PJRVYhK07ERpcOak/5vKK8?=
=?us-ascii?Q?bENBXFjWNtheiHwSwwkgdrDLUK2g2E89f2qvxjdwtddBIyiFlSrHtDL96rGl?=
=?us-ascii?Q?x1Gttt/euV2MdYDJ2yemW2NTmQtWpT4sW7g3aHnTm9GbFUzA+awEBBmw0ybg?=
=?us-ascii?Q?cxOJbIvwdQzUAX6r5kYJ9x4Dc1I8dVqgtdwAFbnGQjvmkgV3v5+8bEFuov6n?=
=?us-ascii?Q?deLbBxT+7oI9cyoc7K26xBJx6qdJx42KoddAQXGp3aiuCJQ4UB8ZaYPpRuTg?=
=?us-ascii?Q?0SgoS4SKPdhsBTgvv83vfZAB/7IPhq2c9dGwnuRdP1Ok1UJz5F6Mnk9OrDRW?=
=?us-ascii?Q?yl0USBBzaM+AH+13gYFtBPzCx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?=
=?us-ascii?Q?6nT9ZRJRdRk/vYm/oDORNekssWGYv0DQcvVpwrsjZqB+5f8QVcU/oTzobdHp?=
=?us-ascii?Q?spM0oI7uMkGwrXeU1il+bjF7ZxDb8yOn+/klIU6ARfvbNGPmeTpg6WKXB2d6?=
=?us-ascii?Q?/AR3PNmyMHxaIigtfcc=3D?=
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM8PR09MB7095.namprd09.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 189c0f8e-605c-403e-d68d-08da5790a32c
X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jun 2022 16:26:35.0410 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 14b77578-9773-42d5-8507-251ca2dc2b06
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR09MB5704
X-OriginatorOrg: ncbi.nlm.nih.gov
X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_EF, KAM_LOTSOFHASH, SPAM_BODY, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE,
T_SPF_HELO_PERMERROR autolearn=no autolearn_force=no version=3.4.6
X-Spam-Level: *
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: "Lavrentiev, Anton \(NIH/NLM/NCBI\) \[C\] via Cygwin" <cygwin AT cygwin DOT com>
Reply-To: "Lavrentiev, Anton \(NIH/NLM/NCBI\) \[C\]" <lavr AT ncbi DOT nlm DOT nih DOT gov>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

There's another discrepancy for execlp() on Cygwin.  In the absence of the PATH environment, it should consider the current directory first, then look up somewhere else.
And it does so on Linux!  Not on Cygwin, though.  Please take a look below:

Linux:

$ ./hello
exec: No such file or directory
$ unset PATH
$ echo $PATH

$ ./hello
Hello

Cygwin:

$ ./hello
exec: No such file or directory
$ unset PATH

$ echo $PATH
$ ./hello
exec: No such file or directory

Anton Lavrentiev
Contractor NIH/NLM/NCBI

> -----Original Message-----
> From: Cygwin <cygwin-bounces+lavr=ncbi DOT nlm DOT nih DOT gov AT cygwin DOT com> On Behalf Of Lavrentiev,
> Anton (NIH/NLM/NCBI) [C] via Cygwin
> Sent: Sunday, June 26, 2022 11:10 AM
> To: 'cygwin AT cygwin DOT com' <cygwin AT cygwin DOT com>
> Subject: [EXTERNAL] Cygwin's execlp() does not work with an empty $PATH element
> 
> Hi all,
> 
> An empty PATH element (":xxx" or "xxx::xxx" or "xxx:") is to be considered as the current
> directory (from the very first days of Unix).
> 
> However, Cygwin does not seem to obey the rule.
> 
> Consider the following simple C program:
> 
> $ cat hello.c
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
> 
> int main(int argc, const char* argv[])
> {
>     if (argc < 2) {
>         const char* prog = strrchr(argv[0], '/');
>         if (!prog++)
>            prog = argv[0];
>         execlp(prog, prog, "Hello", NULL);  // execute just by the program name
>         perror("exec");
>         return 1;
>     }
>     printf("%s\n", argv[1]);
>     return 0;
> }
> 
> Now compare the execution on Linux and Cygwin:
> 
> Linux:
> 
> $ gcc -Wall -o hello hello.c
> $ hello
> bash: hello: command not found
> $ ./hello
> exec: No such file or directory
> $ PATH=".:$PATH" ./hello
> Hello
> $ PATH=":$PATH" ./hello
> Hello
> $ PATH="${PATH}:" ./hello
> Hello
> 
> Cygwin:
> 
> $ gcc -Wall -o hello hello.c
> $ hello
> -bash: hello: command not found
> $ ./hello
> exec: No such file or directory
> $ PATH=".:$PATH" ./hello
> Hello
> $ PATH=":$PATH" ./hello
> exec: No such file or directory
> $ PATH="${PATH}:" ./hello
> exec: No such file or directory
> 
> As you can see, the execution failed when an empty PATH element was added on Cygwin
> (yet it was perfectly fine on Linux).
> 
> Anton Lavrentiev
> Contractor NIH/NLM/NCBI
> 
> 
> --
> Problem reports:
> https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcygwin.com%2Fproblems.ht
> ml&amp;data=05%7C01%7Clavr%40ncbi.nlm.nih.gov%7C4f115d6612d84622f36e08da578602f6%7C14b7757
> 8977342d58507251ca2dc2b06%7C0%7C0%7C637918530342421084%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4
> wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=5W%2FkRL
> P2C5dOS1mAwXbXjeW3jLCNm3Kn%2BCFMJbPlgyo%3D&amp;reserved=0
> FAQ:
> https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcygwin.com%2Ffaq%2F&amp;
> data=05%7C01%7Clavr%40ncbi.nlm.nih.gov%7C4f115d6612d84622f36e08da578602f6%7C14b77578977342
> d58507251ca2dc2b06%7C0%7C0%7C637918530342421084%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMD
> AiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=vYE4PpDSlT6%2Fw
> jApZyC8r1BjQULY4MmBH2nUJIXE3BQ%3D&amp;reserved=0
> Documentation:
> https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcygwin.com%2Fdocs.html&a
> mp;data=05%7C01%7Clavr%40ncbi.nlm.nih.gov%7C4f115d6612d84622f36e08da578602f6%7C14b77578977
> 342d58507251ca2dc2b06%7C0%7C0%7C637918530342421084%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA
> wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=pbcpGI8Ykvb5
> UQlP%2FOT6G2ZUXloiARlZvax0NhyO2t0%3D&amp;reserved=0
> Unsubscribe info:
> https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcygwin.com%2Fml%2F%23uns
> ubscribe-
> simple&amp;data=05%7C01%7Clavr%40ncbi.nlm.nih.gov%7C4f115d6612d84622f36e08da578602f6%7C14b
> 77578977342d58507251ca2dc2b06%7C0%7C0%7C637918530342421084%7CUnknown%7CTWFpbGZsb3d8eyJWIjo
> iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=DGMP
> SVCqWNO6qKi6BCqKvvWxBD4x2m2vUfBCIHfI9Ts%3D&amp;reserved=0


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019