我有一个文件描述符存储在变量中,比如说var。如何在以后的阶段检查该描述符是否有效?
fdvar1= open(.....);
fdvar2 = fdvar1; // Please ignore the bad design
....
// lots of loops , conditionals and threads. It can call close(fdvar2) also.
....
if(CheckValid(fdvar1)) // How can I do this check ?
write(fdvar1, ....);
现在,我想检查 var1 是否仍然有效(持有已打开的描述符)。 有没有相应的API可以用?
dup
的手册页面。 - Some programmer dude