fcntl

fcntl is a command available within the TclX package. Here is the appropriate part of its man page.

fcntl fileId attribute ?value?

This command either sets or clears an option for an open file channel (called fileId) or returns its current value. If value is not specified, then the current value of attribute is returned. All values are boolean. Some attributes maybe only be read, not modified. The following attributes may be specified (all are read-write unless otherwise specified):

RDONLY
The file is opened for reading only. (Get only)
WRONLY
The file is opened for writing only. (Get only)
RDWR
The file is opened for reading and writing. (Get only)
READ
If the file is readable. (Get only).
WRITE
If the file is writable. (Get only).
APPEND
The file is opened for append-only writes. All writes will be atomically forced to the end of the file.
NONBLOCK
The file is to be accessed with non-blocking I/O. See the read system call for a description of how it affects the behavior of file reads. (This is also controllable through fconfigure's -blocking option.)
CLOEXEC
Close the file on an process exec. If the execl command or some other mechanism causes the process to do an exec, the file will be closed if this option is set.
NOBUF
The file is not buffered. If set, then there no buffering for the file.
LINEBUF
Output the file will be line buffered. The buffer will be flushed when a newline is written, when the buffer is full, or when input is requested. If not set and NOBUF is not set, the buffer will be flushed when it is full.
KEEPALIVE
Keep a socket connection alive. If SIGPIPE is enabled, then it is sent if connection is broken and data is written to the socket. If SIGPIPE is ignored, an error is returned on the write. This attribute is valid only on sockets. By default, SIGPIPE is ignored in Tcl.

The NONBLOCK, NOBUF and LINEBUF are provided for compatibility with older scripts. The fconfigure command is preferred method of getting and setting these attributes.

The APPEND and CLOEXEC options are not available on Windows 95/NT.