From 7cb0eb6f3be00172b1a54cfcd206ab753ec96c67 Mon Sep 17 00:00:00 2001 From: David Timber Date: Fri, 22 Mar 2024 13:55:27 +0900 Subject: More on flock_mmap, fix the Makefile --- flock_mmap/Makefile | 2 +- flock_mmap/README.md | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/flock_mmap/Makefile b/flock_mmap/Makefile index 0275f91..f55485d 100644 --- a/flock_mmap/Makefile +++ b/flock_mmap/Makefile @@ -1,4 +1,4 @@ -CC := cc +CC ?= cc OBJ = flock_mmap lock do: build test diff --git a/flock_mmap/README.md b/flock_mmap/README.md index 623fd5c..36ce390 100644 --- a/flock_mmap/README.md +++ b/flock_mmap/README.md @@ -26,7 +26,7 @@ make 2> /dev/null ``` ### Result A -- Linux +- Linux: glibc, ulibc, musl ``` ./tests.sh @@ -48,3 +48,22 @@ make 2> /dev/null [TEST]flock() and close() unlocks the file*: YES [TEST]flock() and holding unlocks the file : NO ``` + +## WHY? +Not sure. Just don't mix `mmap()` with `flock()`, I guess. + +``` +HISTORY + 4.4BSD (the flock() call first appeared in 4.2BSD). A version of + flock(), possibly implemented in terms of fcntl(2), appears on most + UNIX systems. +``` +``` +VERSIONS + Since Linux 2.0, flock() is implemented as a system call in its own + right rather than being emulated in the GNU C library as a call to fc‐ + ntl(2). With this implementation, there is no interaction between the + types of lock placed by flock() and fcntl(2), and flock() does not de‐ + tect deadlock. (Note, however, that on some systems, such as the mod‐ + ern BSDs, flock() and fcntl(2) locks do interact with one another.) +``` -- cgit