lua: subprocess: support cancellation on Windows

This commit is contained in:
James Ross-Gowan
2014-11-18 13:20:59 +11:00
committed by wm4
parent 9e77ba8003
commit c644178098

View File

@@ -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;
}