diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-01-08 20:02:15 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-01-08 20:02:15 +0100 |
commit | 4603af2492b7d11f66f8c03e1b38b1429eaf799e (patch) | |
tree | 688d14acde0b977d227f6bed594ce474237148ce /src | |
parent | a02c4f829a9d4321c7fd10812f1ef77795405520 (diff) |
waitpid after kill
Diffstat (limited to 'src')
-rw-r--r-- | src/AsyncImageLoader.cpp | 2 | ||||
-rw-r--r-- | src/Downloader.cpp | 10 | ||||
-rw-r--r-- | src/Program.cpp | 2 |
3 files changed, 12 insertions, 2 deletions
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<std::mutex> 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; |