operating system services an ioerror exception is raised if the fcntl(function fails the f_getlk and f_setlk commands are supported through the lockf(function ioctl(fdoparg [mutate_flag]this function is like the fcntl(functionexcept that the operations supplied in op are generally defined in the library module termios the extra mutate_flag controls the behavior of this function when mutable buffer object is passed as an argument further details about this can be found in the online documentation because the primary use of ioctl(is to interact with device-drivers and other low-level components of the operating systemits use depends highly on the underlying platform it should not be used in code that aims to be portable flock(fdopperforms lock operationopon the file descriptor fd op is the bitwise or of the following constantswhich are found in fnctlitem description lock_ex exclusive lock all further attempts to acquire the lock will block until the lock is released non-blocking mode returns immediately with an ioerror if the lock is already in use shared lock blocks any attempts to acquire an exclusive lock (lock_ex)but shared locks can still be acquired unlock releases any previous held lock lock_nb lock_sh lock_un in nonblocking modean ioerror exception is raised if the lock cannot be acquired on some systemsthe process of opening and locking file can be performed in single operation by adding special flags to the os open(operation consult the os module for more details lockf(fdop [len [start [whence]]]performs record or range locking on part of file op is the same as for the flock(function len is the number of bytes to lock start is the starting position of the lock relative to the value of whence whence is for the beginning of the file for the current positionand for the end of the file example import fcntl open file open("foo"," "set the close-on-exec bit for file object fcntl fcntl( fileno()fcntl f_setfd lock file (blockingfcntl flock( fileno()fcntl lock_exf lib fl ff