9.) How do I `lock' a file?
-
a) Use filelock()
-
b) use lockfile()
-
c) Use lockfd()
-
d) use fcntl()
D
Correct answer
Explanation
fcntl() is the POSIX system call used for advisory and mandatory file locking in Unix/Linux systems. It operates on file descriptors and provides mechanisms like shared and exclusive locks through the F_SETLK and F_SETLKW commands. The other options (filelock(), lockfile(), lockfd()) are not standard POSIX system calls.