X-Recipient: archive-cygwin@delorie.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" To: "Cygwin" Subject: execvp() runs programs from cwd even if '.' is not in PATH From: "Christian Franke" Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Message-ID: <1NBPAK-1lORIe0@fwd05.aul.t-online.de> X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Delivered-To: mailing list cygwin@cygwin.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 < #include 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