by evmar · 4y ago · 0 comments
https://github.com/ninja-build/ninja/commit/89587196705f54af...
What you need is an operation like "close all descriptors >= N", as posix_spawn opcode.
I've implemented closefrom() type APIs more than once. Of course, I happen to know about Illumos', so there's that.
[0] http://src.illumos.org/source/search?project=illumos-gate&full=posix_spawn_file_actions_addclosefrom_np&defs=&refs=&path=&hist=&type=&xrd=&nn=1
[1] https://docs.oracle.com/cd/E36784_01/html/E36874/posix-spawn-file-actions-addclosefrom-np-3c.htmlIt won't close descriptor 4096, but that's probably beyond giving a darn in most cases. If you have an application that opens high descriptor numbers, you probably know.