Multiple choice technology operating systems

16 How can I find out if someone else has a file open?

  1. 1 Its not possible

  2. 2 use isused() function

  3. 3 Try to open file with locking enabled

  4. 4 Try to write the file after opening

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

There is no direct function like isused() to check if another process has a file open. The standard approach is to use file locking (flock, fcntl) - if you can acquire an exclusive lock, no one else has it open. Option C suggests trying to open with locking enabled, which is the closest practical method.

AI explanation

One reliable way to check whether another process has a file open is to attempt to open it yourself with file locking enabled (e.g., an exclusive lock); if the lock request fails or blocks, that tells you someone else currently holds it open. There's no portable isused() function, and simply trying to write to the file doesn't reliably reveal another process's open handle since many systems allow concurrent writes without contention.