This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Use a default path in exec*p*() if PATH is unset?
On 4/11/2017 3:02 PM, Christian Franke wrote:
> cyg Simple wrote:
>>
>> -i, --ignore-environment start with an empty environment
>>
>> A relative use of the executable will not be found if the environment is
>> empty.
>
> Not necessarily (see Linux, *BSD, ...). POSIX says this is
> "implementation-defined" - under the assumption that 'env' uses execvp()
> which is the case for the GNU coreutils version.
>
> POSIX says this is "implementation-defined"
Which means it is undefined by POSIX. Also one could argue that
--ignore-environment also means any default ones within an API set.
>
>>> Interestingly the approach in newlib/libc/posix/execvp.c differs from
>>> Cygwin and others:
>>> execvp() with PATH unset calls execv(). This has the same effect as
>>> execvp() with PATH set to current directory only.
>>>
>> Why do you assume that this is an issue with execvp?
>
> I never did (otherwise this would be a thread on cygwin-patches list).
>
> The above only means that it is IMO interesting that the Cygwin source
> package contains two implementations of execvp() which handle the unset
> PATH situation differently.
>
Sure, but it is implemented correctly based on POSIX. ;)
>
>> The user should
>> not expect that an undefined behavior behaves the same way on other
>> systems.
>
> Of course. But even then it is a reasonable question which possible
> alternative should be implemented by Cygwin. Cygwin homepage says "Get
> that Linux feeling, ...". So "implementation-defined" behavior should
> possibly be close to Linux :-)
>
Even so not all "Linux feeling" can be implemented. But I agree it
should be as close as possible.
But I don't believe that env --ignore-environment should be using execvp
and should be using execv instead. That is for the upstream coreutils
team to decide though.
--
cyg 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