Bug 16339

Summary: close_range() returns ENOSYS, breaking fork+exec under current systemd
Product: [Yocto Project Subprojects] Pseudo Reporter: Vincent Haupert <mail>
Component: pseudoAssignee: Vincent Haupert <mail>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium+ CC: bbnpreetsingh, david.c.nystrom, randy.macleod, tim.orling, yp.pseudo.watcher, yp.watcher
Version: master   
Target Milestone: 6.1 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Vincent Haupert 2026-06-30 22:08:19 UTC
Bug 14526 added close_range() interception, but the wrapper just sets `errno = ENOSYS`. That stub breaks callers which treat ENOSYS as fatal rather than retrying.

Current systemd is one such caller. close_all_fds() closes descriptors via close_range(), and safe_fork_full() aborts the child if that fails, so under pseudo every fork+exec fails. systemd has called close_range() here since v247 (2020), but only began treating a failure as fatal in v260, which raised its kernel baseline to 5.10 and dropped the previous /proc fallback.

A concrete trigger is building a disk image with "pseudo systemd-repart", which
dies as soon as repart spawns mkfs:

    Failed to close all file descriptors: Function not implemented
    '(mkfs)' failed with exit status 1.

close_range() has been in the kernel since 5.9 (2020) and glibc since 2.34 (2021), so this increasingly affects common tooling.

Could pseudo implement close_range() rather than returning ENOSYS?
Comment 1 Paul Barker 2026-07-02 18:15:31 UTC
Hi Vincent,

We need a little more info so we can understand your issue.

Which Yocto Project version are you using? I'm a little confused as we have systemd v259.5 in master currently, so no current version of the project has systemd v260 or later.

What task is running `systemd-repart` under pseudo? Is this something added by one of your own layers or by a vendor BSP?

Thanks,
Paul
Comment 2 Vincent Haupert 2026-07-02 18:27:19 UTC
Hi Paul,

Thanks for coming back to me so quickly!

I'm actually not using pseudo for Yocto, but under NixOS. Specifically, I want to use pseudo instead of fakeroot to build an image with systemd-repart, because pseudo supports nftw (which fakeroot lacks). You can find more information here: https://github.com/NixOS/nixpkgs/issues/455331

Thanks,
Vincent
Comment 3 Randy MacLeod 2026-07-09 14:43:54 UTC
close_range can be implemented in pseudo but we haven't done that yet.
It would be a nice addition.

Do you want to submit a patch ?
Comment 4 Babanpreet Singh 2026-07-15 15:19:01 UTC
I don’t mean to interfere at all but I sent a patch for this. Please defer that patch if Vincent is already in progress/is working on it. He didn’t reply, hence I saw an opportunity to work on it. I’m happy to defer if needed.
Comment 5 Vincent Haupert 2026-07-15 17:42:08 UTC
(In reply to Babanpreet Singh from comment #4)
> I don’t mean to interfere at all but I sent a patch for this. Please defer
> that patch if Vincent is already in progress/is working on it. He didn’t
> reply, hence I saw an opportunity to work on it. I’m happy to defer if
> needed.

I didn't start anything yet, so your patch is more than welcome!
Comment 6 David Nyström 2026-10-15 09:05:16 UTC
Fixed by f85e2ae9ad9112efbbda2dd3daeb05a1144b0842 — "ports/linux/guts: Implement close_range() instead of returning ENOSYS" by Babanpreet Singh