process-util: handle pidfd_spawn() returning E2BIG
authorKornilios Kourtis <kornilios@gmail.com>
Thu, 15 Aug 2024 15:22:35 +0000 (17:22 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Aug 2024 17:04:57 +0000 (02:04 +0900)
commit7ac58157ca67ab001307f1fd72e0cc7c0c4e846a
tree2e6b00344c3e63292b43fb062616792c49277eba
parentc8e7cfeddc7be498c688c564f31676b856181120
process-util: handle pidfd_spawn() returning E2BIG

In some kernels (specifically, 5.4) even though the clone3 syscall is
supported, setting CLONE_INTO_CGROUP is not. The error message returned
in this case is E2BIG.

If posix_spawn_wrapper encounters this error, it does not retry, and
cannot spawn any programs in said kernels.

This commit adds a check for the E2BIG error and retries pidfd_spawn()
without the POSIX_SPAWN_SETCGROUP flag.

If we encounter an E2BIG error, and the pidfd_spawn() succeeds after
removing the POSIX_SPAWN_SETCGROUP flag, then we cache the result so
that we do not retry every time.

Originally, this issue was reported in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1077204.

Signed-off-by: Kornilios Kourtis <kornilios@gmail.com>
src/basic/process-util.c