Fix file descriptor leaking in exec