To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: chmod() corrupts file handle Date: Sun, 11 Dec 94 14:06:17 +0200 From: "Eli Zaretskii" Somebody reported here that his file handle was corrupted by a call to chmod(), and that he saw an error when he later called close(). I've lost that posting, but it seems that I don't have that problem. A short program attached to this message runs OK when compiled both by Borland C 3.1 and DJGPP 1.12m2. Perhaps the original poster could give more details about the problem he is experiencing, as it seems to be at least not as general as the original message implied. Of course, an obvious question that I would ask anybody who writes for DOS is: why bother about f?chmod() at all? It seldom makes any sense in DOS anyway, so why not just #ifdef it out? -------------------- cut here --------------------------- #include #include #ifdef __TURBOC__ #include #else #include #endif #include #include void main(int argc, char *argv[]) { if (argc > 1) { char *file = argv[1]; int fh = open(file, O_RDONLY); if (fh == -1) { perror(file); exit(1); } if (chmod(file, S_IREAD)) { perror("chmod"); exit(1); } if (close(fh)) { perror("close"); exit(1); } exit(0); } fprintf(stderr, "Usage: %s file\n", argv[0]); exit(2); }