c++ - fstat() problem
- Carlos (36/36) Sep 25 2008 There is a problem with the fstat() function, which does not
- Walter Bright (1/1) Sep 27 2008 http://bugzilla.digitalmars.com/issues/show_bug.cgi?id=27
There is a problem with the fstat() function, which does not identify bad file descriptor. Using: Digital Mars C/C++ Compiler Version 8.51.0n Illustraded by the snippet: #include <sys\stat.h> #include <stdio.h> #include <errno.h> #include <stdlib.h> int main( int argc, char**argv ) { struct stat buf; int status, fd; fd = atoi(argv[1]); status = fstat(fd,&buf); printf( "called fstat( %d, &buf )\n", fd ); printf( "status: %d\n", status ); printf( "errno: %d\n", errno ); perror("fstat()"); return 0; } C:> fstat 2 <-- gives no error. which is Ok. called fstat( 2, &buf ) status: 0 errno: 0 fstat(): No error C:> fstat 343 <-- gives no error. which is an error! called fstat( 343, &buf ) status: 0 errno: 0 fstat(): No error ---> The output should be: called fstat( 343, &buf ) status: -1 errno: 9 fstat(): Bad file descriptor Carlos
Sep 25 2008
http://bugzilla.digitalmars.com/issues/show_bug.cgi?id=27
Sep 27 2008