Fix setting of close on exec flag.