This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

execvp() runs programs from cwd even if '.' is not in PATH


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]