Use a default path in exec*p*() if PATH is unset?
Thu Apr 13 04:29:00 GMT 2017
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
> 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
> 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.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin