This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: execvp* and spawnvp* react differently to same PATH environment variable
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Wed, 9 Oct 2019 16:43:08 +0000
- Subject: Re: execvp* and spawnvp* react differently to same PATH environment variable
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none
- 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-SenderADCheck; bh=oiYYoeOeHoHxMDnjoONTPdLgnmOsByBYDilj9JIPsg8=; b=gnptmf7cWnx0Ou+qNUichGrV0/onS28PDoGxqNQl2bdAh/UbW6yIfVSl29U947LKw2TNnsIP83By8TM//CJMHa9c99cIZbbd1G14p5/41+eSRIpcAj8lTd4cLX4PvcK9N0BDMRr6NFw4KoSrL/bZwWmyAfgtudU/C6gZJPrFbiqXlGxVJsvFy9khDceL6R6Vz4woHeSn0qWME/qyFhlo/qCs7oO7czrs941XR1fUEsRckv44gNzwiqVNvBBtNC3eYlVBHI/nGDuUvOWOpaDJ01XlVbnv45zUNqKa88WiGWugIxKmMTtmLtcO4hC005OB09s6VO3xRD5Hnl3geKwmDw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eTTEqQAosT2dgj4AJdlzL8B1djqzBFmFQqponTSZ1FkwH3IOjkGGa0GJNl5l85uf4JA+bdHP0fjJiD+arKErqcrDhiWxSljXOafzpr7r3GT0zh7hYgPo2tU5niaxEEIiFVlUvgU+h7Afah0YjAQ2FISPkDoS2GSJ0DsKWySOJAtMgbq/ARfD6nQWXMwPlVVi2f/bhQYgnexPrEi0ulo+4LZTsecZY2/AjKFJOzM7ZqwHy4XuTA98nZCvw/TJdiRQJzDgC5qF2FVaNuv+xjBnb9Ag1uGbwbPbdc9cHSGwuqskXsQXfhg5ZLrHWoz1drt9bXAJTVHtp7JxG496/EhJSw==
- References: <1549599310.1980812.1570481495155.JavaMail.zimbra@tdcadsl.dk>
On 10/7/2019 4:51 PM, donpedro.tdcadsl.dk via cygwin wrote:
> Hi all,
>
> While working on something i noticed that execvp* and spawnvp* behave differently with regards to $PATH, which i think is not correct.
>
> ----------------------------------------------
>
> 1) The execvp* functions are called like this:
>
> return spawnve ( _P_OVERLAY | _P_PATH_TYPE_EXEC ,
> find_exec ( file , buf , "PATH" , FE_NNF ) ? : "" ,
> argv , envp );
>
> This calls find_exec() with FE_NNF, which causes the path to be NULL if not found in $PATH.
>
> This later causes cygwin to fail correctly if the program is not in $PATH.
>
> ----------------------------------------------
>
> 2) The spawnvp* functions are called like this:
>
> return spawnve (mode | _P_PATH_TYPE_EXEC, find_exec (file, buf), argv, cur_environ ());
>
> This does _not_ calls find_exec() with FE_NNF which causes the path to be the posix form, as it is not found in path.
>
> This later causes cygwin to find the program even though it was not in $PATH which seems wrong.
>
> ----------------------------------------------
>
> This seems like a bug in spawnvp* functions unless i am missing something?
I think you're probably right. The use of FE_NNF in execvp* was introduced in
commit 6d63272b. I suspect it was just an oversight that the spawvp* functions
weren't changed in the same way. I'll send a patch to the cygwin-patches list
to fix this. When Corinna returns, she can tell us whether there's some reason
that spawnvp should be different from execvp.
Ken
--
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