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?
[email protected] 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).
[email protected] 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
[email protected] (Scott Lurndal) wrote:
[email protected] 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
[email protected] (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.
[email protected] writes:
On Sat, 01 Oct 2022 19:21:03 GMT
[email protected] (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.
[email protected] writes:
On Sat, 01 Oct 2022 19:21:03 GMT
[email protected] (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.
[email protected] 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: | 715 |
| Nodes: | 16 (3 / 13) |
| Uptime: | 143:01:37 |
| Calls: | 12,089 |
| Calls today: | 2 |
| Files: | 14,998 |
| Messages: | 6,517,457 |