Hi, all,
Here i try to open a file, close it, and then try to close it again:
The outputs are:Code:int fd, result; fd = open("myfile", O_RDONLY); printf("file descriptor: %d\n", fd); result = close(fd); printf("first close: %d\n", result); result = close(fd); printf("second close: %d\n", result);
file descriptor: 9
first close: 0
second close: 0
However as we close the file at the first time, when we close it at the second time, the result returned should be -1 which is an error number. Why it still returns 0?
Thank you!



LinkBack URL
About LinkBacks


