I'm implementing a library to run commands. The library is C, on Linux.
It currently does a popen() call to run a command and get output. The problem is that the command inherits all currently open file handlers.
If I did a fork/exec I could close the handlers in child explicitly. But that means re-implementing popen().
Can I set close-on-exec on all handlers without looping through them one by one?
Can I set close-on-exec as default for the process?
Thanks!