Function Reference
— Built-in Function: [err, msg] = fcntl (fid, request, arg)

Change the properties of the open file fid. The following values may be passed as request:

F_DUPFD
Return a duplicate file descriptor.
F_GETFD
Return the file descriptor flags for fid.
F_SETFD
Set the file descriptor flags for fid.
F_GETFL
Return the file status flags for fid. The following codes may be returned (some of the flags may be undefined on some systems).
O_RDONLY
Open for reading only.
O_WRONLY
Open for writing only.
O_RDWR
Open for reading and writing.
O_APPEND
Append on each write.
O_CREAT
Create the file if it does not exist.
O_NONBLOCK
Nonblocking mode.
O_SYNC
Wait for writes to complete.
O_ASYNC
Asynchronous I/O.

F_SETFL
Set the file status flags for fid to the value specified by arg. The only flags that can be changed are O_APPEND and O_NONBLOCK.

If successful, err is 0 and msg is an empty string. Otherwise, err is nonzero and msg contains a system-dependent error message.