-
-
Save jnthn/f660e30516a1f803e8a598a3d082c336 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/io/procops.c b/src/io/procops.c | |
index eb4c573..154f409 100644 | |
--- a/src/io/procops.c | |
+++ b/src/io/procops.c | |
@@ -181,6 +181,7 @@ typedef struct { | |
char **args; | |
uv_stream_t *stdin_handle; | |
MVMuint32 had_stdin_handle; | |
+ int stdin_bound_handle; | |
MVMuint32 seq_stdout; | |
MVMuint32 seq_stderr; | |
MVMuint32 seq_merge; | |
@@ -501,6 +502,12 @@ static void async_spawn_on_exit(uv_process_t *req, MVMint64 exit_status, int ter | |
close_stdin(tc, os_handle); | |
uv_mutex_unlock(mutex); | |
+ /* Close any stdin we were bound to. */ | |
+ if (si->stdin_bound_handle) { | |
+ close(si->stdin_bound_handle); | |
+ si->stdin_bound_handle = 0; | |
+ } | |
+ | |
/* Close handle. */ | |
uv_close((uv_handle_t *)req, spawn_async_close); | |
((MVMIOAsyncProcessData *)((MVMOSHandle *)si->handle)->body.data)->handle = NULL; | |
@@ -681,6 +688,7 @@ static void spawn_setup(MVMThreadContext *tc, uv_loop_t *loop, MVMObject *async_ | |
process_stdio[0].flags = UV_INHERIT_FD; | |
process_stdio[0].data.fd = (int)MVM_repr_get_int(tc, | |
MVM_repr_at_key_o(tc, si->callbacks, tc->instance->str_consts.stdin_fd)); | |
+ si->stdin_bound_handle = process_stdio[0].data.fd; | |
} | |
else { | |
process_stdio[0].flags = UV_INHERIT_FD; | |
@@ -801,6 +809,11 @@ static void spawn_setup(MVMThreadContext *tc, uv_loop_t *loop, MVMObject *async_ | |
MVM_repr_push_o(tc, arr, msg_box); | |
MVM_repr_push_o(tc, ((MVMAsyncTask *)async_task)->body.queue, arr); | |
} | |
+ | |
+ if (si->stdin_bound_handle) { | |
+ close(si->stdin_bound_handle); | |
+ si->stdin_bound_handle = 0; | |
+ } | |
}); | |
MVM_io_eventloop_remove_active_work(tc, &(si->work_idx)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment