File Descriptor and I/O Control
fcntl
Supported functionality in SCML:
ignore_flags = O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC;
can_change_flags = O_APPEND | O_ASYNC | O_DIRECT | O_NOATIME | O_NONBLOCK;
// Duplicate a file descriptor
fcntl(fd, cmd = F_DUPFD | F_DUPFD_CLOEXEC, arg);
// Retrieve file descriptor flags (F_GETFD), file status flags (F_GETFL)
// or SIGIO/SIGURG owner process (F_GETOWN)
fcntl(fd, cmd = F_GETFD | F_GETFL | F_GETOWN);
// Set file descriptor flags
fcntl(fd, cmd = F_SETFD, arg = FD_CLOEXEC);
// Set file status flags
fcntl(fd, cmd = F_SETFL, arg = <ignore_flags> | <can_change_flags>);
// Manage record locks: test (F_GETLK), non-blocking set (F_SETLK), blocking set (F_SETLKW)
fcntl(fd, cmd = F_GETLK | F_SETLK | F_SETLKW, arg);
// Assign SIGIO/SIGURG owner process
fcntl(fd, cmd = F_SETOWN, arg);
Unsupported commands:
F_NOTIFYF_OFD_SETLK,F_OFD_SETLKWandF_OFD_GETLKF_GETOWN_EXandF_SETOWN_EXF_GETSIGandF_SETSIGF_SETLEASEandF_GETLEASEF_SETPIPE_SZandF_GETPIPE_SZF_ADD_SEALSandF_GET_SEALSF_GET_RW_HINTandF_SET_RW_HINTF_GET_FILE_RW_HINTandF_SET_FILE_RW_HINT
For more information, see the man page.
pipe and pipe2
Supported functionality in SCML:
// Create pipe
pipe(pipefd);
// Create pipe with enhanced behavior control
pipe2(pipefd, flags = O_CLOEXEC);
Silently-ignored flags:
O_DIRECTO_NONBLOCK
For more information, see the man page.
eventfd and eventfd2
Supported functionality in SCML:
// Create event notification descriptor
eventfd(initval);
// Create event notification descriptor with enhanced behavior control
eventfd2(initval, flags = EFD_CLOEXEC);
Silently-ignored flags:
EFD_NONBLOCKEFD_SEMAPHORE
For more information, see the man page.