If a process does flock() on a file then dies without unlocking it, does unix >clear that lock or is it left hanging? The man pages and google are silent on >this. Ditto whether LOCK_UN can block?
Also a related question - is there a command line tool that will show/remove >advisory locks and who owns them?
Muttley@dastardlyhq.com writes:
If a process does flock() on a file then dies without unlocking it,
does unix clear that lock or is it left hanging? The man pages and
google are silent on this. Ditto whether LOCK_UN can block?
Also a related question - is there a command line tool that will
show/remove advisory locks and who owns them?
"All locks associated with a file for a given process shall be removed
when a file descriptor for that file is closed by that process or the
process holding that file descriptor terminates. Locks are not inherited
by a child process."
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
(note: flock() is a bsd-ism and is not described by POSIX/SuS).
Muttley@dastardlyhq.com writes:
If a process does flock() on a file then dies without unlocking it, does unix >>clear that lock or is it left hanging? The man pages and google are silent on >>this. Ditto whether LOCK_UN can block?
Also a related question - is there a command line tool that will show/remove >>advisory locks and who owns them?
"All locks associated with a file for a given process shall be removed
when a file descriptor for that file is closed by that process or the
process holding that file descriptor terminates. Locks are not inherited
by a child process."
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
(note: flock() is a bsd-ism and is not described by POSIX/SuS).
I'm not aware of any command to show the locks. I'm not aware of any >kernel/filesystem API that provides that visibility.
On Sat, 01 Oct 2022 19:21:03 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
Muttley@dastardlyhq.com writes:
If a process does flock() on a file then dies without unlocking it, does unix
clear that lock or is it left hanging? The man pages and google are silent on
this. Ditto whether LOCK_UN can block?
Also a related question - is there a command line tool that will show/remove >>>advisory locks and who owns them?
"All locks associated with a file for a given process shall be removed
when a file descriptor for that file is closed by that process or the
process holding that file descriptor terminates. Locks are not inherited >> by a child process."
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
(note: flock() is a bsd-ism and is not described by POSIX/SuS).
Didn't know, though its available on Linux and MacOS so clearly is fairly >widespread.
On Sat, 01 Oct 2022 19:21:03 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
I'm not aware of any command to show the locks. I'm not aware of any >>kernel/filesystem API that provides that visibility.
Pity. Some rainy day I'll have to trawl /proc on linux and see if anything looks like a list of file locks for a process.
Muttley@dastardlyhq.com writes:
On Sat, 01 Oct 2022 19:21:03 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
[...]
I'm not aware of any command to show the locks. I'm not aware of any >>>kernel/filesystem API that provides that visibility.
Pity. Some rainy day I'll have to trawl /proc on linux and see if anything >> looks like a list of file locks for a process.
The (virtual) file /proc/locks lists all currently held file locks. The
pid of the process holding the lock is in the fifth column.
Muttley@dastardlyhq.com writes:
On Sat, 01 Oct 2022 19:21:03 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
[...]
I'm not aware of any command to show the locks. I'm not aware of any >>>kernel/filesystem API that provides that visibility.
Pity. Some rainy day I'll have to trawl /proc on linux and see if anything >> looks like a list of file locks for a process.
The (virtual) file /proc/locks lists all currently held file locks. The
pid of the process holding the lock is in the fifth column.
Muttley@dastardlyhq.com writes:
If a process does flock() on a file then dies without unlocking it, does unix >>clear that lock or is it left hanging? The man pages and google are silent on >>this. Ditto whether LOCK_UN can block?
Also a related question - is there a command line tool that will show/remove >>advisory locks and who owns them?
"All locks associated with a file for a given process shall be removed
when a file descriptor for that file is closed by that process or the
process holding that file descriptor terminates. Locks are not inherited
by a child process."
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
(note: flock() is a bsd-ism and is not described by POSIX/SuS).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 299 |
Nodes: | 16 (2 / 14) |
Uptime: | 83:18:33 |
Calls: | 6,696 |
Calls today: | 1 |
Files: | 12,229 |
Messages: | 5,347,919 |