Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177396075
D55801.1794286588.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D55801.1794286588.diff
View Options
diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c
--- a/usr.sbin/watchdogd/watchdogd.c
+++ b/usr.sbin/watchdogd/watchdogd.c
@@ -49,6 +49,7 @@
#include <math.h>
#include <paths.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -68,6 +69,7 @@
static int watchdog_init(void);
static int watchdog_onoff(int onoff);
static int watchdog_patpat(sbintime_t);
+static int watchdog_control(u_int);
static void usage(void);
static int tvtohz(struct timeval *tv);
@@ -86,6 +88,8 @@
static int is_dry_run = 0; /* do not arm the watchdog, only
report on timing of the watch
program */
+static bool no_fork = false;
+static bool need_timeout = false;
static int do_timedog = 0;
static int do_syslog = 1;
static int fd = -1;
@@ -130,6 +134,11 @@
openlog("watchdogd", LOG_CONS|LOG_NDELAY|LOG_PERROR,
LOG_DAEMON);
+ /* Retrieve old timeout if necessary */
+ if (need_timeout)
+ ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
+ else
+ ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
rtp.type = RTP_PRIO_REALTIME;
rtp.prio = 0;
if (rtprio(RTP_SET, 0, &rtp) == -1)
@@ -152,7 +161,7 @@
warn("Cannot open or create pidfile");
}
- if (debugging == 0 && daemon(0, 0) == -1) {
+ if (debugging == 0 && !no_fork && daemon(0, 0) == -1) {
watchdog_onoff(0);
pidfile_remove(pfh);
err(EX_OSERR, "daemon");
@@ -347,7 +356,7 @@
}
if (failed == 0)
- watchdog_patpat(timeout);
+ watchdog_control(WD_CTRL_RESET);
waited = watchdog_check_dogfunction_time(&ts_start, &ts_end);
if (nap - waited > 0)
@@ -653,7 +662,7 @@
is_daemon = 1;
if (is_daemon)
- getopt_shortopts = "I:de:ns:t:ST:wx:?";
+ getopt_shortopts = "I:Dde:ns:t:ST:wx:?";
else
getopt_shortopts = "dt:?";
@@ -663,6 +672,9 @@
case 'I':
pidfile = optarg;
break;
+ case 'D':
+ no_fork = true;
+ break;
case 'd':
debugging = 1;
break;
@@ -685,8 +697,11 @@
break;
case 't':
timeout_sec = atoi(optarg);
- timeout = parse_timeout_to_sbt(c, NULL, optarg);
- if (debugging)
+ if (timeout_sec == -1)
+ need_timeout = true;
+ else
+ timeout = parse_timeout_to_sbt(c, NULL, optarg);
+ if (debugging && !need_timeout)
printf("Timeout is %d\n",
(int)(timeout / SBT_1S));
break;
@@ -734,7 +749,7 @@
if (argc != optind)
errx(EX_USAGE, "extra arguments.");
- if (is_daemon && timeout < WD_TO_1SEC)
+ if (is_daemon && timeout < SBT_1S)
errx(EX_USAGE, "-t argument is less than one second.");
if (pretimeout_set) {
if (pretimeout >= timeout_sec) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 10, 4:56 AM (1 m, 22 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41627957
Default Alt Text
D55801.1794286588.diff (2 KB)
Attached To
Mode
D55801: watchdog: Add no-daemon mode and '-t -1' option
Attached
Detach File
Event Timeline