Questions tagged [flock]

28 questions
2
votes
1 answer

When I use flock it exits immediately instead of waiting

I was confused for a very long time with the meaning of the -n flag for flock(1). Basically there are many guides for this tool, and often what we see is some command like flock -n 100. Here, fd number 100 is associated with some lockfile and used…
Steven Lu
  • 2,282
0
votes
1 answer

Why can flock(1) do inter-process lock?

flock is associated with open-file-description, and open(2) creates new open-file-description. So invoking flock(1) in two separate shells will open the lock file separately and result in two open-file-descriptions. How could flock(1) know the lock…