Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Injected-Via-Gmane: http://gmane.org/ To: cygwin AT cygwin DOT com From: Andrew DeFaria Subject: Re: Problem in executable file mechanism Date: Thu, 17 Apr 2003 11:00:51 -0700 Lines: 38 Message-ID: <3E9EEBD3.5070305@Salira.com> References: <20030416163529 DOT GQ11137 AT cygbert DOT vinschen DOT de> <20030417090005 DOT GU11137 AT cygbert DOT vinschen DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT main DOT gmane DOT org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en, ru, zh Corinna Vinschen wrote: > On Wed, Apr 16, 2003 at 12:58:20PM -0400, Igor Pechtchanski wrote: > >> On Wed, 16 Apr 2003, Corinna Vinschen wrote: >> >>> On Wed, Apr 16, 2003 at 11:56:32AM -0400, Igor Pechtchanski wrote: >>> >>>> Try "strace sh -c ls". >>>> Igor >>> >>> Well... let's get serious. What do you expect? Think UNIX. The >>> executable is 'ls'. The directory is 'ls'. This is only possible on >>> Windows because the executables have this .exe suffix. On UNIX this >>> won't be a problem since there wouldn't be two files with the same >>> name in a directory. >>> >>> Corinna >> >> Yes. But since such a mechanism *was* introduced in Cygwin, shouldn't >> the executable take precedence, at least for an exec() call? I can't >> think of a situation when anyone would want to exec() a directory... > > That's not the point. The point is that calls like stat() will find > "/usr/bin/ls" before finding "/usr/bin/ls.exe". That's correct in 99% > of the cases. Just in the coincidental case of having a dir and > a binary of the same name in the same directory, returning "ls" before > "ls.exe" is incorrect. But, honestly, how should stat() know that its > behaviour should suddenly be different than in the other 99% cases? > > The answer to the original posters problem is that simple: Don't do this. Couldn't exec (shouldn't exec) stat /usr/bin/ls as expected but then see that that is a directory and then continue on in the algorithm to stat /usr/bin/ls.exe? Again, just because you found a candidate (/usr/bin/ls) does not mean that you should necessarily attempt to run it (i.e. run a directory!). -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/