Skip to content

Commit ca9bb05

Browse files
committed
try to fix non-stopped vlc processes
1 parent 1d32266 commit ca9bb05

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

process_unix.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,12 @@ void Process::kill(bool force) noexcept {
484484
std::lock_guard<std::mutex> lock(close_mutex);
485485
if(data.id > 0 && !closed) {
486486
if(force) {
487-
::kill(-data.id, SIGTERM);
488-
::kill(data.id, SIGTERM); // Based on comment in https://gitlab.com/eidheim/tiny-process-library/-/merge_requests/29#note_1146144166
487+
::kill(-data.id, SIGKILL);
488+
::kill(data.id, SIGKILL); // Based on comment in https://gitlab.com/eidheim/tiny-process-library/-/merge_requests/29#note_1146144166
489489
}
490490
else {
491-
::kill(-data.id, SIGINT);
492-
::kill(data.id, SIGINT);
491+
::kill(-data.id, SIGTERM);
492+
::kill(data.id, SIGTERM);
493493
}
494494
}
495495
}
@@ -499,12 +499,12 @@ void Process::kill(id_type id, bool force) noexcept {
499499
return;
500500

501501
if(force) {
502-
::kill(-id, SIGTERM);
503-
::kill(id, SIGTERM);
502+
::kill(-id, SIGKILL);
503+
::kill(id, SIGKILL);
504504
}
505505
else {
506-
::kill(-id, SIGINT);
507-
::kill(id, SIGINT);
506+
::kill(-id, SIGTERM);
507+
::kill(id, SIGTERM);
508508
}
509509
}
510510

streambasehandler.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ bool StreamBaseHandler::streamVideo(const m3u_stream &stream) {
7575
return true;
7676
}
7777

78-
bool StreamBaseHandler::isRunning(int &exit_status) {
79-
return streamHandler->try_get_exit_status(exit_status);
80-
}
81-
8278
bool StreamBaseHandler::streamAudio(const m3u_stream &stream) {
8379
// sanity check
8480
stop();
@@ -152,10 +148,17 @@ bool StreamBaseHandler::streamAudio(const m3u_stream &stream) {
152148

153149
void StreamBaseHandler::stop() {
154150
if (streamHandler!=nullptr) {
151+
int pid = streamHandler->get_id();
152+
155153
streamHandler->kill(true);
156154
streamHandler->get_exit_status();
157155
delete streamHandler;
158156
streamHandler = nullptr;
157+
158+
159+
if (0 == kill(pid, 0)) {
160+
printf("PID still exists....: %d\n", pid);
161+
}
159162
}
160163

161164
std::lock_guard<std::mutex> guard(queueMutex);
@@ -165,6 +168,11 @@ void StreamBaseHandler::stop() {
165168

166169
int StreamBaseHandler::popPackets(unsigned char *bufferAddrP, unsigned int bufferLenP) {
167170
std::lock_guard<std::mutex> guard(queueMutex);
171+
172+
if (streamHandler == nullptr) {
173+
return 0;
174+
}
175+
168176
if (!tsPackets.empty()) {
169177
std::string front = tsPackets.front();
170178

streambasehandler.h

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class StreamBaseHandler {
1717
bool streamVideo(const m3u_stream &stream);
1818
bool streamAudio(const m3u_stream &stream);
1919
void stop();
20-
bool isRunning(int &exit_status);
2120

2221
int popPackets(unsigned char *bufferAddrP, unsigned int bufferLenP);
2322

0 commit comments

Comments
 (0)