mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Avoid prematurely closing file descriptors when redirecting IO
This commit is contained in:
		| @@ -1145,14 +1145,16 @@ static Janet os_execute_impl(int32_t argc, Janet *argv, int is_spawn) { | ||||
|         posix_spawn_file_actions_addclose(&actions, pipe_in); | ||||
|     } else if (new_in != JANET_HANDLE_NONE && new_in != 0) { | ||||
|         posix_spawn_file_actions_adddup2(&actions, new_in, 0); | ||||
|         posix_spawn_file_actions_addclose(&actions, new_in); | ||||
|         if (new_in != new_out && new_in != new_err) | ||||
|             posix_spawn_file_actions_addclose(&actions, new_in); | ||||
|     } | ||||
|     if (pipe_out != JANET_HANDLE_NONE) { | ||||
|         posix_spawn_file_actions_adddup2(&actions, pipe_out, 1); | ||||
|         posix_spawn_file_actions_addclose(&actions, pipe_out); | ||||
|     } else if (new_out != JANET_HANDLE_NONE && new_out != 1) { | ||||
|         posix_spawn_file_actions_adddup2(&actions, new_out, 1); | ||||
|         posix_spawn_file_actions_addclose(&actions, new_out); | ||||
|         if (new_out != new_err) | ||||
|             posix_spawn_file_actions_addclose(&actions, new_out); | ||||
|     } | ||||
|     if (pipe_err != JANET_HANDLE_NONE) { | ||||
|         posix_spawn_file_actions_adddup2(&actions, pipe_err, 2); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Camilleri
					Michael Camilleri