1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Refactored and added more error checking.

This commit is contained in:
Antti Seppälä 2007-10-19 18:26:27 +00:00
parent 5dc7117720
commit 5ed04a6e72

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: protocolext.c,v 1.5 2007/10/19 18:03:19 ajhseppa Exp $
* $Id: protocolext.c,v 1.6 2007/10/19 18:26:27 ajhseppa Exp $
*/
#include <sys/wait.h>
@ -142,12 +142,16 @@ void cIptvProtocolExt::TerminateCommand(void)
const unsigned int timeoutms = 100;
unsigned int waitms = 0;
siginfo_t waitStatus;
int retval = 0;
bool waitOver = false;
// signal and wait for termination
kill(pid, SIGINT);
int retval = kill(pid, SIGINT);
if (retval < 0) {
char tmp[64];
error("ERROR: kill(): %s", strerror_r(errno, tmp, sizeof(tmp)));
waitOver = true;
}
do {
while (!waitOver) {
retval = 0;
waitms += timeoutms;
if ((waitms % 2000) == 0) {
@ -160,7 +164,7 @@ void cIptvProtocolExt::TerminateCommand(void)
retval = waitid(P_PID, pid, &waitStatus, WNOHANG | WEXITED);
if (retval < 0) {
char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
error("ERROR: waitid(): %s", strerror_r(errno, tmp, sizeof(tmp)));
waitOver = true;
}
// These are the acceptable conditions under which child exit is
@ -175,7 +179,7 @@ void cIptvProtocolExt::TerminateCommand(void)
// Unsuccessful wait, avoid busy looping
if (!waitOver)
cCondWait::SleepMs(timeoutms);
} while (!waitOver);
}
pid = -1;
isActive = false;