3
5
Fork 0
mirror of git://git.savannah.gnu.org/guix.git synced 2023-12-14 03:33:07 +01:00

syscalls: 'with-lock-file' catches ENOSYS.

* guix/build/syscalls.scm (call-with-file-lock): Catch ENOSYS raised by
'lock-file'.
This commit is contained in:
Ludovic Courtès 2019-06-03 17:13:30 +02:00
parent 89ceb86ad4
commit 5f0cf1df71
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1084,13 +1084,24 @@ exception if it's already taken."
#t)
(define (call-with-file-lock file thunk)
(let ((port (lock-file file)))
(let ((port (catch 'system-error
(lambda ()
(lock-file file))
(lambda args
;; When using the statically-linked Guile in the initrd,
;; 'fcntl-flock' returns ENOSYS unconditionally. Ignore
;; that error since we're typically the only process running
;; at this point.
(if (= ENOSYS (system-error-errno args))
#f
(apply throw args))))))
(dynamic-wind
(lambda ()
#t)
thunk
(lambda ()
(unlock-file port)))))
(when port
(unlock-file port))))))
(define-syntax-rule (with-file-lock file exp ...)
"Wait to acquire a lock on FILE and evaluate EXP in that context."