From 22c9087a6f1fb32aadfff3fa54c0548a7293539c Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Sat, 27 Jun 2026 15:56:23 +0300 Subject: [PATCH 1/2] std: treat ENFILE as transient in the pidfd support probe The probe handles EMFILE (per-process fd limit) as a transient error and re-probes later, but lets ENFILE (system-wide fd limit) fall through to the catch-all arm meant for an old kernel without pidfd support, which permanently caches the pidfd path as unsupported. ENFILE is the same transient condition, so handle both. --- library/std/src/sys/process/unix/unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/process/unix/unix.rs b/library/std/src/sys/process/unix/unix.rs index 529cdaf72cc6c..1dd684975c2dd 100644 --- a/library/std/src/sys/process/unix/unix.rs +++ b/library/std/src/sys/process/unix/unix.rs @@ -510,7 +510,7 @@ impl Command { support = SPAWN; } } - Err(e) if e.raw_os_error() == Some(libc::EMFILE) => { + Err(e) if matches!(e.raw_os_error(), Some(libc::EMFILE | libc::ENFILE)) => { // We're temporarily(?) out of file descriptors. In this case pidfd_spawnp would also fail // Don't update the support flag so we can probe again later. return Err(e) From 77e396d08db606c7d4529391f0b029027db0c093 Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Sun, 28 Jun 2026 11:10:47 +0300 Subject: [PATCH 2/2] std: treat ENOMEM as transient in the pidfd support probe --- library/std/src/sys/process/unix/unix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/process/unix/unix.rs b/library/std/src/sys/process/unix/unix.rs index 1dd684975c2dd..b6ccc6b698fda 100644 --- a/library/std/src/sys/process/unix/unix.rs +++ b/library/std/src/sys/process/unix/unix.rs @@ -510,8 +510,8 @@ impl Command { support = SPAWN; } } - Err(e) if matches!(e.raw_os_error(), Some(libc::EMFILE | libc::ENFILE)) => { - // We're temporarily(?) out of file descriptors. In this case pidfd_spawnp would also fail + Err(e) if matches!(e.raw_os_error(), Some(libc::EMFILE | libc::ENFILE | libc::ENOMEM)) => { + // We're temporarily(?) out of file descriptors or memory. In this case pidfd_spawnp would also fail // Don't update the support flag so we can probe again later. return Err(e) }