- 论坛徽章:
- 95
|
原帖由 barbas 于 2007-6-15 19:07 发表
man fcntl
F_GETFD
Read the close-on-exec flag. If the FD_CLOEXEC bit is 0, the file will remain open across exec, otherwise it
will be closed.
F_SETFD
...
可以参考下这个:
The close-on-exec flag for a file descriptor tells whether the file descriptor should remain open across exec-calls. So when the Tcl interpreter has heaps of files open and the close-on-exec flag is not set, the exec'ed command will inherit all these file descriptors. If the close-on-exec flag is set on some file descriptors, those will be closed on exec, so that the subprocess cannot read/write the open descriptors and cannot keep the file open even if the Tcl interpreter terminates.
This would cause trouble if the file was to be deleted (which physically takes place when the file is no longer open) or - even worse - if the file is a pipe. In this case the other process dealing with the pipe will believe that there is still a reader/writer and won't detect EOF or "no reader present", hence keep waiting.
原文地址
http://athena.wolf.eu.org/~wolf/dupa/wiki.tcl.tk/6030 |
|