www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-2.2 required=5.0 tests=AWL,BAYES_00 |
X-Spam-Check-By: | sourceware.org |
MIME-Version: | 1.0 |
Date: | Fri, 20 Nov 2009 09:48:28 +0100 |
Reply-To: | "Christian Franke" <Christian DOT Franke AT t-online DOT de> |
To: | "Cygwin" <cygwin AT cygwin DOT com> |
Subject: | execvp() runs programs from cwd even if '.' is not in PATH |
From: | "Christian Franke" <Christian DOT Franke AT t-online DOT de> |
Message-ID: | <1NBPAK-1lORIe0@fwd05.aul.t-online.de> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |