mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 12:05:19 -06:00
build/syscalls: Smooth failure mode of (thread-count).
* guix/build/syscalls.scm (thread-count): Use 1 as a fallback when /proc/self/task could not be read, and return a count value (rather than a list). (unshare): Adjust accordingly. Fixes: #4231 Change-Id: Idcd59a4d2c211df3f2b832e912199f6a7f15e684
This commit is contained in:
parent
ed42337b4e
commit
9e77e52dc3
1 changed files with 13 additions and 6 deletions
|
|
@ -1271,11 +1271,18 @@ memory (CLONE_VM) or threads (CLONE_THREAD) are shared with it."
|
|||
(pid (parent pid))))
|
||||
|
||||
(define (thread-count)
|
||||
"Return the complete thread count of the current process. Unlike
|
||||
`all-threads', this also counts the Guile signal delivery, and finalizer
|
||||
threads."
|
||||
(scandir "/proc/self/task"
|
||||
(negate (cut member <> '("." "..")))))
|
||||
"Return the complete thread count of the current process. If it could not
|
||||
be retrieved, a warning is emitted and the value 1 is used as a fallback.
|
||||
Unlike `all-threads', this also counts the Guile signal delivery, and
|
||||
finalizer threads."
|
||||
(match (scandir "/proc/self/task" (negate (cut member <> '("." ".."))))
|
||||
(#f
|
||||
;; This can happen, for example in containers where /proc is not
|
||||
;; exposed.
|
||||
(format (current-warning-port)
|
||||
"warning: thread count not available; returning 1~%")
|
||||
1)
|
||||
(x (length x))))
|
||||
|
||||
(define unshare
|
||||
(let ((proc (syscall->procedure int "unshare" (list int))))
|
||||
|
|
@ -1293,7 +1300,7 @@ with EINVAL."
|
|||
flags))
|
||||
(warn/maybe (lambda ()
|
||||
(when (and require-single-thread?
|
||||
(< 1 (length (thread-count))))
|
||||
(< 1 (thread-count)))
|
||||
(format (current-warning-port)
|
||||
"warning: unshare single-thread \
|
||||
requirement violated~%")))))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue