Open file descriptors with O_CLOEXEC.

Without this, file descriptors could be passed to subprocesses spawned during
file operations.
Add copyright and license block.