From 4603af2492b7d11f66f8c03e1b38b1429eaf799e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 8 Jan 2024 20:02:15 +0100 Subject: waitpid after kill --- src/AsyncImageLoader.cpp | 2 ++ src/Downloader.cpp | 10 ++++++++-- src/Program.cpp | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp index 8b8c5f6..2b454da 100644 --- a/src/AsyncImageLoader.cpp +++ b/src/AsyncImageLoader.cpp @@ -399,6 +399,8 @@ namespace QuickMedia { std::lock_guard lock(download_mutex); if(download.read_program.pid != -1) { kill(download.read_program.pid, SIGTERM); + int status; + waitpid(download.read_program.pid, &status, 0); download.read_program.pid = -1; } if(download.read_program.read_fd != -1) { diff --git a/src/Downloader.cpp b/src/Downloader.cpp index 75cef1c..2c0d316 100644 --- a/src/Downloader.cpp +++ b/src/Downloader.cpp @@ -80,8 +80,11 @@ namespace QuickMedia { bool CurlDownloader::stop(bool download_completed) { if(read_program.read_fd != -1) close(read_program.read_fd); - if(read_program.pid != -1) + if(read_program.pid != -1) { kill(read_program.pid, SIGTERM); + int status; + waitpid(read_program.pid, &status, 0); + } if(!download_completed) remove(output_filepath_tmp.data.c_str()); //header_reader.cancel(); @@ -269,8 +272,11 @@ namespace QuickMedia { bool YoutubeDlDownloader::stop(bool) { if(read_program_file) fclose(read_program_file); - if(read_program.pid != -1) + if(read_program.pid != -1) { kill(read_program.pid, SIGTERM); + int status; + waitpid(read_program.pid, &status, 0); + } // TODO: Remove the temporary files created by youtube-dl (if !download_completed) //header_reader.cancel(); finished = false; diff --git a/src/Program.cpp b/src/Program.cpp index c82476e..de30e4f 100644 --- a/src/Program.cpp +++ b/src/Program.cpp @@ -97,6 +97,8 @@ public: } if(it->second.program.pid != -1) { kill(it->second.program.pid, SIGTERM); + int status; + waitpid(it->second.program.pid, &status, 0); it->second.program.pid = -1; } it->second.killed = true; -- cgit v1.2.3