summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2024-02-10 19:16:16 +0100
committersfan5 <sfan5@live.de>2024-02-11 14:13:22 +0100
commitca5f7d2b4b1d00020a56dcfd6319f0acb7157d27 (patch)
treeeed8abc50a14cbcd56477b7bae26abb7d7063768
parent71598ca07eec3715ab6c0fce9f89be1c1c3b0798 (diff)
downloadmpv-ca5f7d2b4b1d00020a56dcfd6319f0acb7157d27.tar.bz2
mpv-ca5f7d2b4b1d00020a56dcfd6319f0acb7157d27.tar.xz
osdep: fix infinite loop when cancelling subprocess
Due to the state of the other fds/pipes it cannot safely be assumed that the loop breaks on its own.
-rw-r--r--osdep/subprocess-posix.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/osdep/subprocess-posix.c b/osdep/subprocess-posix.c
index 0656ec5df1..c75d267cdd 100644
--- a/osdep/subprocess-posix.c
+++ b/osdep/subprocess-posix.c
@@ -281,7 +281,7 @@ void mp_subprocess2(struct mp_subprocess_opts *opts,
if (pid)
kill(pid, SIGKILL);
killed_by_us = true;
- break;
+ goto break_poll;
}
struct mp_subprocess_fd *fd = &opts->fds[n];
if (fd->on_read) {
@@ -316,6 +316,8 @@ void mp_subprocess2(struct mp_subprocess_opts *opts,
}
}
+break_poll:
+
// Note: it can happen that a child process closes the pipe, but does not
// terminate yet. In this case, we would have to run waitpid() in
// a separate thread and use pthread_cancel(), or use other weird