summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM. Sean Finney <seanius@users.sourceforge.net>2005-05-01 20:12:03 +0000
committerM. Sean Finney <seanius@users.sourceforge.net>2005-05-01 20:12:03 +0000
commit1cd64d081d1745436dd7c41826dfb05672dd26aa (patch)
treeada88d06239ac42dc15db353c15e6186a5a82fcc
parent205dda8d6e2922661cd4c33c94cb42739b397920 (diff)
downloadmonitoring-plugins-1cd64d081d1745436dd7c41826dfb05672dd26aa.tar.gz
better error checking in spopen signal handler (see 1107524)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1169 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/popen.c6
-rw-r--r--plugins/popen.h8
2 files changed, 9 insertions, 5 deletions
diff --git a/plugins/popen.c b/plugins/popen.c
index 04eb3881..062cf274 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -243,8 +243,12 @@ static int openmax = 0;
243void 243void
244popen_timeout_alarm_handler (int signo) 244popen_timeout_alarm_handler (int signo)
245{ 245{
246 int fh;
246 if (signo == SIGALRM) { 247 if (signo == SIGALRM) {
247 kill (childpid[fileno (child_process)], SIGKILL); 248 fh=fileno (child_process);
249 if(fh >= 0){
250 kill (childpid[fh], SIGKILL);
251 }
248 printf (_("CRITICAL - Plugin timed out after %d seconds\n"), 252 printf (_("CRITICAL - Plugin timed out after %d seconds\n"),
249 timeout_interval); 253 timeout_interval);
250 exit (STATE_CRITICAL); 254 exit (STATE_CRITICAL);
diff --git a/plugins/popen.h b/plugins/popen.h
index 1f4e413a..c2a79df0 100644
--- a/plugins/popen.h
+++ b/plugins/popen.h
@@ -9,7 +9,7 @@ int spclose (FILE *);
9RETSIGTYPE popen_timeout_alarm_handler (int); 9RETSIGTYPE popen_timeout_alarm_handler (int);
10 10
11extern unsigned int timeout_interval; 11extern unsigned int timeout_interval;
12pid_t *childpid; 12pid_t *childpid=NULL;
13int *child_stderr_array; 13int *child_stderr_array=NULL;
14FILE *child_process; 14FILE *child_process=NULL;
15FILE *child_stderr; 15FILE *child_stderr=NULL;