execlp/execvp needs case-correct PATH
Corinna Vinschen
corinna-cygwin@cygwin.com
Wed Feb 11 16:49:00 GMT 2015
On Feb 10 20:14, Thomas Wolff wrote:
> Am 10.02.2015 um 10:27 schrieb Corinna Vinschen:
> >On Feb 9 21:49, Thomas Wolff wrote:
> >>Am 09.02.2015 um 11:17 schrieb Corinna Vinschen:
> >>>On Feb 9 00:04, Thomas Wolff wrote:
> >>>>With a Windows case sensitive file system (and according mount flags
> >>>>for /cygdrive), the PATH does not properly reflect casing of the actual
> >>>>directories (e.g. C:\WINDOWS vs. C:\Windows, thanks MS...).
> >>>>However, the shell finds programs anyway, like e.g. notepad.
> >>>>The exec*p system calls, on the other hand, do not find a program in this
> >>>>case as demonstrated by the attached test program.
> >>>>This is in contrast to the Linux (and POSIX?) manual page which claims
> >>>>„The execlp(), execvp(), and execvpe() functions duplicate the actions
> >>>>of the shell in searching for an executable file …“
> >>>...
> >>Sorry, I forgot one detail: I added /cygdrive/c/Windows/System32 to my path
> >>so the shell will find it, but yet execlp does not find it.
> >Which makes sense, given that notepad is not in C:\Windows\System32, but in C:\Windows.
> On my systems (Windows 7 Professional/Ultimate) it’s in both C:\Windows and
> C:\Windows\System32
> (otherwise the shell wouldn’t have found it after adding to the path).
>> However, I could resolve the issue partly by putting
> /cygdrive/c/Windows (or ../System32) in the path *before* the bogus
> /cygdrive/c/WINDOWS - weird, but this way exec*p works.
>> With the old setting (bogus first in path), apparently/assumedly exec*p
> somehow finds the file in /cygdrive/c/WINDOWS but then cannot start it from
> there because of the case mis-match.
> There’s still the inconsistency with shell behaviour.
I found the cause. The function searching for executables in $PATH was
searching on the Win32 PATH variable. The underlying conversion
functionality treats Win32 paths with default flags. I revamped the
search function to iterate over the POSIX PATH variable so the
posix=[0|1] mount flag is taken into account. As a nice side effect,
the search function is mow much simpler and easier to understand.
I tested this new stuff in a variety of situations, but there's still
the chance that I missed something. So this needs a good, sturdy testing.
I just uploaded new snapshots to the usual place:
https://cygwin.com/snapshots/
Please give it a try.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150211/2733cf01/attachment.sig>
More information about the Cygwin
mailing list