close on exec

As far as I know there is currently no way to manipulate the close-on-exec flag from Tcl.

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.

DKF: By default, Tcl's FDs are closed on exec. To pass them on, you need to use the right kind of redirection (and that only works for standard channels).