Since those are chunks of code based on our codebase, it's easiest to use the same license.
At various places we only want to close fds if they are not stdin/stdout/stderr, i.e. fds 0, 1, 2. Let's add a unified helper call for that, and port everything over.