projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
32acbdd
)
contrib/package: reap zombies in freifunk-watchdog, fix a warning
author
Jo-Philipp Wich
<jow@openwrt.org>
Sun, 4 Oct 2009 18:11:47 +0000
(18:11 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Sun, 4 Oct 2009 18:11:47 +0000
(18:11 +0000)
contrib/package/freifunk-watchdog/Makefile
patch
|
blob
|
history
contrib/package/freifunk-watchdog/src/watchdog.c
patch
|
blob
|
history
contrib/package/freifunk-watchdog/src/watchdog.h
patch
|
blob
|
history
diff --git
a/contrib/package/freifunk-watchdog/Makefile
b/contrib/package/freifunk-watchdog/Makefile
index
7a68afb
..
25c4efa
100644
(file)
--- a/
contrib/package/freifunk-watchdog/Makefile
+++ b/
contrib/package/freifunk-watchdog/Makefile
@@
-8,7
+8,7
@@
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-watchdog
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-watchdog
-PKG_RELEASE:=
6
+PKG_RELEASE:=
7
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_BUILD_DEPENDS := uci
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_BUILD_DEPENDS := uci
diff --git
a/contrib/package/freifunk-watchdog/src/watchdog.c
b/contrib/package/freifunk-watchdog/src/watchdog.c
index
b87bed0
..
2d6e4a6
100644
(file)
--- a/
contrib/package/freifunk-watchdog/src/watchdog.c
+++ b/
contrib/package/freifunk-watchdog/src/watchdog.c
@@
-21,10
+21,18
@@
/* Global watchdog fd, required by signal handler */
int wdfd = -1;
/* Global watchdog fd, required by signal handler */
int wdfd = -1;
+/* Handle finished childs */
+static void sigchld_handler(int sig)
+{
+ pid_t pid;
+
+ while( (pid = waitpid(-1, NULL, WNOHANG)) > 0 )
+ syslog(LOG_INFO, "Child returned (pid %d)", pid);
+}
+
/* Watchdog shutdown helper */
static void shutdown_watchdog(int sig)
{
/* Watchdog shutdown helper */
static void shutdown_watchdog(int sig)
{
- static int wdelay = 3600;
static const char wshutdown = WATCH_SHUTDOWN;
if( wdfd > -1 )
static const char wshutdown = WATCH_SHUTDOWN;
if( wdfd > -1 )
@@
-298,7
+306,7
@@
static int do_daemon(void)
int loadavg_panic = 0;
openlog(SYSLOG_IDENT, 0, LOG_DAEMON);
int loadavg_panic = 0;
openlog(SYSLOG_IDENT, 0, LOG_DAEMON);
-
//daemon(1, 1
);
+
memset(&sa, 0, sizeof(sa)
);
if( (iwfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 )
{
if( (iwfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 )
{
@@
-327,6
+335,11
@@
static int do_daemon(void)
ioctl(wdfd, WDIOC_SETTIMEOUT, &wdtimeout);
}
ioctl(wdfd, WDIOC_SETTIMEOUT, &wdtimeout);
}
+ /* Install signal handler to reap childs */
+ sa.sa_handler = sigchld_handler;
+ sa.sa_flags = 0;
+ sigaction(SIGCHLD, &sa, NULL);
+
while( 1 )
{
/* Check/increment action interval */
while( 1 )
{
/* Check/increment action interval */
diff --git
a/contrib/package/freifunk-watchdog/src/watchdog.h
b/contrib/package/freifunk-watchdog/src/watchdog.h
index
6d9ccf8
..
71c10e9
100644
(file)
--- a/
contrib/package/freifunk-watchdog/src/watchdog.h
+++ b/
contrib/package/freifunk-watchdog/src/watchdog.h
@@
-29,6
+29,7
@@
#include <math.h>
#include <time.h>
#include <signal.h>
#include <math.h>
#include <time.h>
#include <signal.h>
+#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@
-67,7
+68,7
@@
/* System load error action and treshold */
#define LOAD_TRESHOLD 15.00
/* System load error action and treshold */
#define LOAD_TRESHOLD 15.00
-#define LOAD_ACTION "/sbin/reboot"
+#define LOAD_ACTION "/sbin/reboot"
, "/sbin/reboot"
/* Fallback binary name (passed by makefile) */
#ifndef BINARY
/* Fallback binary name (passed by makefile) */
#ifndef BINARY
@@
-107,22
+108,20
@@
iw_ioctl(int skfd, /* Socket to the kernel */
}
/* fork() & execl() helper */
}
/* fork() & execl() helper */
-#define EXEC(x) \
- do { \
- switch(fork()) \
- { \
- case -1: \
- syslog(LOG_CRIT, "Unable to fork child: %s", \
- strerror(errno)); \
- \
- break; \
- \
- case 0: \
- execl(x, NULL); \
- syslog(LOG_CRIT, "Unable to execute action: %s", \
- strerror(errno)); \
- \
- return 1; \
- } \
+#define EXEC(x) \
+ do { \
+ switch(fork()) \
+ { \
+ case -1: \
+ syslog(LOG_CRIT, "Unable to fork child: %s", \
+ strerror(errno)); \
+ break; \
+ \
+ case 0: \
+ execl(x, NULL); \
+ syslog(LOG_CRIT, "Unable to execute action: %s", \
+ strerror(errno)); \
+ return 1; \
+ } \
} while(0)
} while(0)