在 POSIX 环境中,当使用系统调用来操作文本文件 ( open(), close(), read(), write()
) 时,有没有办法检查我在使用时是否真的关闭了文件描述符close(file_descriptor)
?
示例:
int main(int argc, char **argv)
{
int input_file; // file descriptor for input file
int output_file; // file descriptor for output file
input_file = open(argv[1], O_RDONLY));
ouput_file = open(argv[2], ...file properties & permissions and crap.....);
// blah blah blah...
close(input_file);
close(output_file);
// what can I code here to check if the file descriptor was actually closed?
}