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]

Re: detecting program invocation from a symbolic link


On Thu, Apr 23, 2009 at 07:18:40PM -0000, ncokwqc02@sneakemail.com wrote:
>I have some C++ code that runs from the command line in a console
>shell.  It is designed to behave differently depending on whether it
>was called directly by name or by a differently named symbolic link.
>This is easy to check under Unix because argv[0] contains the name of
>the first command line argument, which is either the executable name or
>the name of the link.
>
>This doesn't work under Windows, however, because argv[0] always
>contains the name of the program being called whether it is actually on
>the command line or via a link.
>
>Even symbolic links created using 'ln -s' under Cygwin behave this way.
>I'm wondering if there is a way around this problem.  In other words,
>any way for my C++ program to detect the name of the symbolic link if
>one was used to invoke the executable.

When a cygwin program B is run from a cygwin program A and cygwin
program B is a symlink to program C, then when C is eventually run its
argv[0] should be "B", like on UNIX.

None of this works when running B from a non-cygwin program like the
windows command prompt since the windows command prompt doesn't
understand cygwin symlinks.

So, AFAICT, Cygwin does like UNIX.  If you are not seeing this behavior
we need more details and a simple test case to reproduce the problem.

--
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/


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