From owner-svn-src-all@freebsd.org Sun Aug 23 20:39:20 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 749B79C01B6; Sun, 23 Aug 2015 20:39:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 650DFDC1; Sun, 23 Aug 2015 20:39:20 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7NKdKHH002806; Sun, 23 Aug 2015 20:39:20 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7NKdJ3w002804; Sun, 23 Aug 2015 20:39:19 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508232039.t7NKdJ3w002804@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 23 Aug 2015 20:39:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287080 - stable/10/usr.sbin/watchdogd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Aug 2015 20:39:20 -0000 Author: ian Date: Sun Aug 23 20:39:19 2015 New Revision: 287080 URL: https://svnweb.freebsd.org/changeset/base/287080 Log: MFC r286947: Add a new exit-timeout option to watchdogd. Modified: stable/10/usr.sbin/watchdogd/watchdogd.8 stable/10/usr.sbin/watchdogd/watchdogd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/watchdogd/watchdogd.8 ============================================================================== --- stable/10/usr.sbin/watchdogd/watchdogd.8 Sun Aug 23 20:16:13 2015 (r287079) +++ stable/10/usr.sbin/watchdogd/watchdogd.8 Sun Aug 23 20:39:19 2015 (r287080) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 18, 2014 +.Dd May 11, 2015 .Dt WATCHDOGD 8 .Os .Sh NAME @@ -46,6 +46,7 @@ .Op Fl s Ar sleep .Op Fl t Ar timeout .Op Fl T Ar script_timeout +.Op Fl x Ar exit_timeout .Sh DESCRIPTION The .Nm @@ -103,14 +104,25 @@ defaults to the value specified by the .Fl s Ar sleep option. .Pp +The +.Fl x Ar exit_timeout +argument is the timeout period (in seconds) to leave in effect when the +program exits. +Using +.Fl x +with a non-zero value protects against lockup during a reboot by +triggering a hardware reset if the software reboot doesn't complete +before the given timeout expires. +.Pp Upon receiving the .Dv SIGTERM or .Dv SIGINT signals, .Nm -will first instruct the kernel to no longer perform watchdog checks and then -will terminate. +will terminate, after first instructing the kernel to either disable the +timeout or reset it to the value given by +.Fl x Ar exit_timeout . .Pp The .Nm Modified: stable/10/usr.sbin/watchdogd/watchdogd.c ============================================================================== --- stable/10/usr.sbin/watchdogd/watchdogd.c Sun Aug 23 20:16:13 2015 (r287079) +++ stable/10/usr.sbin/watchdogd/watchdogd.c Sun Aug 23 20:39:19 2015 (r287080) @@ -77,6 +77,7 @@ static int debugging = 0; static int end_program = 0; static const char *pidfile = _PATH_VARRUN "watchdogd.pid"; static u_int timeout = WD_TO_128SEC; +static u_int exit_timeout = WD_TO_NEVER; static u_int pretimeout = 0; static u_int timeout_sec; static u_int passive = 0; @@ -461,10 +462,10 @@ watchdog_onoff(int onoff) /* pat one more time for good measure */ return watchdog_patpat((timeout|WD_ACTIVE)); } else { - return watchdog_patpat(0); + return watchdog_patpat(exit_timeout); } failsafe: - watchdog_patpat(0); + watchdog_patpat(exit_timeout); return (error); } @@ -476,8 +477,8 @@ usage(void) { if (is_daemon) fprintf(stderr, "usage:\n" -" watchdogd [-dnSw] [-e cmd] [-I file] [-s sleep] [-t timeout]\n" -" [-T script_timeout]\n" +" watchdogd [-dnSw] [-e cmd] [-I pidfile] [-s sleep] [-t timeout]\n" +" [-T script_timeout] [-x exit_timeout]\n" " [--debug]\n" " [--pretimeout seconds] [-pretimeout-action action]\n" " [--softtimeout] [-softtimeout-action action]\n" @@ -697,7 +698,7 @@ parseargs(int argc, char *argv[]) is_daemon = 1; if (is_daemon) - getopt_shortopts = "I:de:ns:t:ST:w?"; + getopt_shortopts = "I:de:ns:t:ST:wx:?"; else getopt_shortopts = "dt:?"; @@ -741,6 +742,11 @@ parseargs(int argc, char *argv[]) case 'w': do_timedog = 1; break; + case 'x': + exit_timeout = parse_timeout_to_pow2ns(c, NULL, optarg); + if (exit_timeout != 0) + exit_timeout |= WD_ACTIVE; + break; case 0: lopt = longopts[longindex].name; if (!strcmp(lopt, "pretimeout")) {