Avoid socket listening error
Closing all file descriptor above 3 is causing problem to socket() and listen(). Setting FD_CLOEXEC on them solves the problem and should have exactly the same behavior. For a more detailed explanation of the error see my comment here.