mirror of
https://github.com/NixOS/nix
synced 2025-07-06 05:01:48 +02:00
libutil: rename and optimize closeMostFDs
this is only used to close non-stdio files in derivation sandboxes. we
may as well encode that in its name, drop the unnecessary integer set,
and use close_range to deal with the actual closing of files. not only
is this clearer, it also makes sandbox setup on linux fast by 1ms each
(cherry-picked and adapted from
c7d97802e4
)
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
Co-authored-by: John Ericson <git@JohnEricson.me>
This commit is contained in:
parent
af26fe3934
commit
03b258bf97
3 changed files with 28 additions and 8 deletions
|
@ -143,10 +143,10 @@ public:
|
|||
namespace unix {
|
||||
|
||||
/**
|
||||
* Close all file descriptors except those listed in the given set.
|
||||
* Close all file descriptors except stdio fds (ie 0, 1, 2).
|
||||
* Good practice in child processes.
|
||||
*/
|
||||
void closeMostFDs(const std::set<Descriptor> & exceptions);
|
||||
void closeExtraFDs();
|
||||
|
||||
/**
|
||||
* Set the close-on-exec flag for the given file descriptor.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue