argv[0] drops extension?

Brian Ford ford@vss.fsi.com
Fri Sep 17 22:09:00 GMT 2004


$ uname -a
CYGWIN_NT-5.1 fordpc 1.5.12(0.116/4/2) 2004-09-16 11:17 i686 unknown
unknown Cygwin

$ cat argv.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int
main(int argc, char *argv[])
{
    printf("argv[0]: %s\n", argv[0]);

    if (open(argv[0], O_RDONLY|O_BINARY) < 0)
        perror("open");

    return 0;
}

$ gcc -o argv.exe -g -O2 argv.c

$ ./argv
argv[0]: ./argv
open: No such file or directory

$ ./argv.exe
argv[0]: ./argv
open: No such file or directory

Is this expected behavior?  Thanks.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...

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



More information about the Cygwin mailing list