mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 16:33:02 +00:00
lua: subprocess: cancel pending I/O before return
I'm not sure if this is necessary, but it can't hurt, and it's what you're supposed to do before leaving the stack frame that contains the OVERLAPPED object and the buffer. If there is no pending I/O, CancelIo will do nothing and GetOverlappedResult will silently fail.
This commit is contained in:
parent
92316eb740
commit
f2b94a3b49
@ -1422,9 +1422,14 @@ static int subprocess(char **args, struct mp_cancel *cancel, void *ctx,
|
||||
|
||||
done:
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (pipes[i].ol.hEvent) CloseHandle(pipes[i].ol.hEvent);
|
||||
if (pipes[i].read) CloseHandle(pipes[i].read);
|
||||
if (pipes[i].read) {
|
||||
// Cancel any pending I/O (if the process was killed)
|
||||
CancelIo(pipes[i].read);
|
||||
GetOverlappedResult(pipes[i].read, &pipes[i].ol, &r, TRUE);
|
||||
CloseHandle(pipes[i].read);
|
||||
}
|
||||
if (pipes[i].write) CloseHandle(pipes[i].write);
|
||||
if (pipes[i].ol.hEvent) CloseHandle(pipes[i].ol.hEvent);
|
||||
}
|
||||
if (pi.hProcess) CloseHandle(pi.hProcess);
|
||||
talloc_free(tmp);
|
||||
|
Loading…
Reference in New Issue
Block a user