From c6441780982c6d1d4a18f8a33e7e318bf342f1b7 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Tue, 18 Nov 2014 13:20:59 +1100 Subject: lua: subprocess: support cancellation on Windows --- player/lua.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'player/lua.c') diff --git a/player/lua.c b/player/lua.c index 552c45badf..699c928e87 100644 --- a/player/lua.c +++ b/player/lua.c @@ -1360,7 +1360,8 @@ static int subprocess(char **args, struct mp_cancel *cancel, void *ctx, *error = NULL; // List of handles to watch with sparse_wait - HANDLE handles[] = { pipes[0].ol.hEvent, pipes[1].ol.hEvent, pi.hProcess }; + HANDLE handles[] = { pipes[0].ol.hEvent, pipes[1].ol.hEvent, pi.hProcess, + cancel ? mp_cancel_get_event(cancel) : NULL }; for (int i = 0; i < 2; i++) { // Close our copy of the write end of the pipes @@ -1404,6 +1405,13 @@ static int subprocess(char **args, struct mp_cancel *cancel, void *ctx, CloseHandle(pi.hProcess); handles[i] = pi.hProcess = NULL; break; + case 3: + if (pi.hProcess) { + TerminateProcess(pi.hProcess, 1); + *error = "killed"; + goto done; + } + break; default: goto done; } -- cgit v1.2.3