This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] |
When searching for an executable to run, Unix shells check every directory on PATH and stop at the first matching executable found. GNAT.OS_Lib.Locate_Exec_On_Path, however, returned the first matching regular file, even if it wasn't executable. As a result, when an executable tries to find where it is run from, we could end up with a discrepency. To test the issue: create two directories bin1 and bin2. The first one should contain a non-executable "exec" file, the second should contain the result of compiling the following program. Add the directories in that order on the PATH, and run "exec" from the command line. The Unix shell will execute the one from bin2/ (since the one in bin1/ is not executable), and the result of the execution should show that the file was executed from bin2/ with GNAT.OS_Lib; use GNAT.OS_Lib; with Ada.Text_IO; use Ada.Text_IO; procedure Exec is begin Put_Line ("Installed in " & Locate_Exec_On_Path ("exec").all); end Exec; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-02 Emmanuel Briot <briot@adacore.com> * adaint.c (__gnat_locate_exec_on_path): only returns executable files, not any regular file. (__gnat_locate_file_with_predicate): new subprogram.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |