aboutsummaryrefslogtreecommitdiff
path: root/src/Program.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-09 15:54:44 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-09 15:55:18 +0200
commit322513ac417aa7002946a3f203ae1a65f959677a (patch)
tree95144d28741e79b637159c8ddb1a11fe6accf6ef /src/Program.c
parent10fcdec298ccef4971dc6d109222079a0f438004 (diff)
Wait until mpv process dies (prevent zombie), fix crash that happens sometimes when quiting video
Diffstat (limited to 'src/Program.c')
-rw-r--r--src/Program.c13
1 files changed, 13 insertions, 0 deletions
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)