Closed jacereda closed 2 years ago
Should this use AutoCloseFD
?
https://github.com/NixOS/nix/blob/1f7584d24c9e50207d74de26be0771d8377ed695/src/libutil/util.cc#L424
@jacereda FWIW, this isn't “weird”. Per open(2)
, and on Linux only:
The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process.
As you noticed, it's impossible for an application to ensure it's not started with extraneous fds open.
That said, I agree that nix develop
probably shouldn't leak internal file descriptors, and your proposed fix seems sensible.
File descriptors returned by
open
aren't consecutive when enteringnix develop
.I would expect the FDs to be consecutive. This results in a test failure in https://github.com/jart/cosmopolitan/blob/d6a039821f927cc81b71e11f21599ff93e1fed62/test/libc/calls/fcntl_test.c#L61
nix-env (Nix) 2.4