aboutsummaryrefslogtreecommitdiff
path: root/src/Program.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-25 22:52:47 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-25 22:52:47 +0200
commitdfa4e24f72996d507e710fc6839367536237c501 (patch)
treed1d053d064738b7f188f1c5fc760886afec430f2 /src/Program.cpp
parente616d1cc3ad60e314c92a8266a996244e02aaa6f (diff)
Rework youtube redirect code
Diffstat (limited to 'src/Program.cpp')
-rw-r--r--src/Program.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Program.cpp b/src/Program.cpp
index 57d7c61..c0e0eca 100644
--- a/src/Program.cpp
+++ b/src/Program.cpp
@@ -57,9 +57,11 @@ public:
void kill_in_thread(const std::thread::id &thread_id) {
std::lock_guard<std::mutex> lock(thread_current_program_mutex);
auto it = thread_current_program.find(thread_id);
- if(it != thread_current_program.end() && it->second.read_program.pid != -1 && it->second.read_program.read_fd != -1) {
- close(it->second.read_program.read_fd);
- kill(it->second.read_program.pid, SIGTERM);
+ if(it != thread_current_program.end()) {
+ if(it->second.read_program.read_fd != -1)
+ close(it->second.read_program.read_fd);
+ if(it->second.read_program.pid != -1)
+ kill(it->second.read_program.pid, SIGTERM);
it->second.killed = true;
}
}
@@ -282,10 +284,18 @@ void program_clear_current_thread() {
current_thread_program.clear();
}
-void program_kill_in_thread(const std::thread::id &thread_id) {
+void program_kill_in_thread(std::thread::id thread_id) {
current_thread_program.kill_in_thread(thread_id);
}
+bool program_is_dead_in_thread(std::thread::id thread_id) {
+ std::lock_guard<std::mutex> lock(thread_current_program_mutex);
+ auto it = thread_current_program.find(thread_id);
+ if(it != thread_current_program.end())
+ return it->second.killed;
+ return false;
+}
+
bool program_is_dead_in_current_thread() {
return current_thread_program.is_killed();
}