This is the mail archive of the
cygwin
mailing list for the Cygwin project.
execvp() runs programs from cwd even if '.' is not in PATH
- From: "Christian Franke" <Christian dot Franke at t-online dot de>
- To: "Cygwin" <cygwin at cygwin dot com>
- Date: Fri, 20 Nov 2009 09:48:28 +0100
- Subject: execvp() runs programs from cwd even if '.' is not in PATH
- Reply-to: "Christian Franke" <Christian dot Franke at t-online dot de>
execvp() and the other 'p' variants of exec run programs also from
current directory even if '.' is not in the PATH.
The function execvp() simply calls execv(find_exec(path,
temp_path_conv_buf), argv). The function find_exec() returns the path
unchanged if not found in PATH, execv() runs the file from cwd then.
Testcase (1.5.25-15 and 1.7.0-65):
$ cd /tmp
$ cat >execvp.c <<EOF
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv)
{
execvp(argv[1], argv+1);
perror(argv[1]);
return 1;
}
EOF
$ make execvp
cc execvp.c -o execvp
$ cp -p /bin/echo.exe echo1.exe
$ PATH=/bin ./execvp echo1 is this a bug \?
is this a bug ?
Christian
--
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