Created attachment 15483 [details] test.c The pidfd_spawn / pidfd_spawnp functions introduced as part of BZ#30349 will allocate an fd as part of the clone3 call, but only return that fd to their caller if the execve in the child succeeds. If the execve in the child fails, then pidfd_spawn / pidfd_spawnp will reap the child and return an appropriate error code to their caller. This error handling path currently forgets to close the fd, resulting in an fd leak. Trivial test program attached that makes a number of pidfd_spawnp calls, prints the returned error code and returned pidfd, and then lists the contents of /proc/self/fd. The returned error code is correct (ENOENT), and no pidfd is returned, but then the listing step reports a bunch of leaked pidfds floating around.
I am working a patch to fix it, thanks to bring this up.
Fixed on 2.40.