public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* execvp* and spawnvp* react differently to same PATH environment variable
@ 2019-10-07 20:51 donpedro.tdcadsl.dk via cygwin
  2019-10-09 16:43 ` Ken Brown
  0 siblings, 1 reply; 3+ messages in thread
From: donpedro.tdcadsl.dk via cygwin @ 2019-10-07 20:51 UTC (permalink / raw)
  To: cygwin; +Cc: pdtychsen.ext

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? 

Any thoughts?

Thanks,

/pedro







--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: execvp* and spawnvp* react differently to same PATH environment variable
  2019-10-07 20:51 execvp* and spawnvp* react differently to same PATH environment variable donpedro.tdcadsl.dk via cygwin
@ 2019-10-09 16:43 ` Ken Brown
  2019-10-09 23:25   ` Peter Dons Tychsen via cygwin
  0 siblings, 1 reply; 3+ messages in thread
From: Ken Brown @ 2019-10-09 16:43 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: execvp* and spawnvp* react differently to same PATH environment variable
  2019-10-09 16:43 ` Ken Brown
@ 2019-10-09 23:25   ` Peter Dons Tychsen via cygwin
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Dons Tychsen via cygwin @ 2019-10-09 23:25 UTC (permalink / raw)
  To: Ken Brown, cygwin

Hi Ken,

> 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.

Excellent. Thanks for the fast response. I will keep an eye out for
when it lands.

Thanks,

/pedro

--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-09 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 20:51 execvp* and spawnvp* react differently to same PATH environment variable donpedro.tdcadsl.dk via cygwin
2019-10-09 16:43 ` Ken Brown
2019-10-09 23:25   ` Peter Dons Tychsen via cygwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).