From 322513ac417aa7002946a3f203ae1a65f959677a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 9 Aug 2019 15:54:44 +0200 Subject: Wait until mpv process dies (prevent zombie), fix crash that happens sometimes when quiting video --- src/Program.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Program.c') diff --git a/src/Program.c b/src/Program.c index a863fcd..8d20d43 100644 --- a/src/Program.c +++ b/src/Program.c @@ -87,6 +87,19 @@ int exec_program(const char **args, ProgramOutputCallback output_callback, void } } +int wait_program(pid_t process_id) { + int status; + if(waitpid(process_id, &status, WUNTRACED) == -1) { + perror("waitpid failed"); + return -errno; + } + + if(!WIFEXITED(status)) + return -4; + + return WEXITSTATUS(status); +} + int exec_program_async(const char **args, pid_t *result_process_id) { /* 1 arguments */ if(args[0] == NULL) -- cgit v1.2.3