Lines Matching +full:cmd +full:- +full:timeout +full:- +full:ms
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2003-2004 Sean M. Kelly <smkelly@FreeBSD.org>
71 static int watchdog_patpat(u_int timeout);
79 static u_int timeout = WD_TO_128SEC; variable
91 static int fd = -1;
92 static int carp_thresh_seconds = -1;
108 { "pretimeout-action", required_argument, &pretimeout_act_set, 1 },
110 { "softtimeout-action", required_argument, &softtimeout_act_set, 1 },
135 if (rtprio(RTP_SET, 0, &rtp) == -1) in main()
138 if (!is_dry_run && watchdog_init() == -1) in main()
142 if (watchdog_onoff(1) == -1) in main()
155 if (debugging == 0 && daemon(0, 0) == -1) { in main()
178 timeout |= WD_PASSIVE; in main()
180 timeout |= WD_ACTIVE; in main()
181 if (watchdog_patpat(timeout) < 0) in main()
193 ts->tv_sec = ns / 1000000000ULL; in pow2ns_to_ts()
194 ts->tv_nsec = ns % 1000000000ULL; in pow2ns_to_ts()
198 * Convert a timeout in seconds to N where 2^N nanoseconds is close to
211 char shortopt[] = "- "; in parse_timeout_to_pow2ns()
226 printf("Timeout for %s%s " in parse_timeout_to_pow2ns()
228 "(in: %s sec -> out: %jd sec %ld ns -> %d ticks)\n", in parse_timeout_to_pow2ns()
229 longopt ? "-" : "", longopt ? longopt : shortopt, in parse_timeout_to_pow2ns()
234 …errx(1, "Timeout for %s%s is too small, please choose a higher timeout.", longopt ? "-" : "", long… in parse_timeout_to_pow2ns()
265 return (-1); in watchdog_init()
290 const char *cmd_prefix, *cmd; in watchdog_check_dogfunction_time() local
306 cmd = test_cmd; in watchdog_check_dogfunction_time()
309 cmd = "stat(\"/etc\", &sb)"; in watchdog_check_dogfunction_time()
314 cmd_prefix, cmd, sec, (long)tv.tv_usec, in watchdog_check_dogfunction_time()
319 cmd_prefix, cmd, sec, (long)tv.tv_usec, in watchdog_check_dogfunction_time()
323 * Adjust the sleep interval again in case syslog(3) took a non-trivial in watchdog_check_dogfunction_time()
367 watchdog_patpat(timeout|WD_ACTIVE); in watchdog_loop()
370 if (nap - waited > 0) in watchdog_loop()
371 sleep(nap - waited); in watchdog_loop()
423 error = watchdog_patpat((timeout|WD_ACTIVE)); in watchdog_onoff()
455 return watchdog_patpat((timeout|WD_ACTIVE)); in watchdog_onoff()
472 " watchdogd [-dnSw] [-e cmd] [-I pidfile] [-s sleep] [-t timeout]\n" in usage()
473 " [-T script_timeout] [-x exit_timeout]\n" in usage()
474 " [--debug]\n" in usage()
475 " [--pretimeout seconds] [-pretimeout-action action]\n" in usage()
476 " [--softtimeout] [-softtimeout-action action]\n" in usage()
479 fprintf(stderr, "usage: watchdog [-d] [-t timeout]\n"); in usage()
500 errx(EX_USAGE, "--%s argument %s", longopt, errstr); in fetchtimeout()
502 errx(EX_USAGE, "-%c argument %s", opt, errstr); in fetchtimeout()
532 act_tbl[i].at_act) == -1) in timeout_act_error()
536 warnx("bad --%s argument '%s' must be one of (%s).", in timeout_act_error()
574 tv->tv_sec = ts->tv_sec; in tstotv()
575 tv->tv_usec = ts->tv_nsec / 1000; in tstotv()
618 * If ints have 32 bits, then the maximum value for any timeout in in tvtohz()
619 * 10ms ticks is 248 days. in tvtohz()
621 sec = tv->tv_sec; in tvtohz()
622 usec = tv->tv_usec; in tvtohz()
624 sec--; in tvtohz()
631 usec -= 1000000; in tvtohz()
638 ticks = (sec * 1000000 + (unsigned long)usec + (tick - 1)) in tvtohz()
642 + ((unsigned long)usec + (tick - 1)) / tick + 1; in tvtohz()
685 /* Get the default value of timeout_sec from the default timeout. */ in parseargs()
686 pow2ns_to_ts(timeout, &ts); in parseargs()
694 if (argv[0][c - 1] == 'd') in parseargs()
703 &longindex)) != -1) { in parseargs()
730 timeout = parse_timeout_to_pow2ns(c, NULL, optarg); in parseargs()
732 printf("Timeout is 2^%d nanoseconds\n", in parseargs()
733 timeout); in parseargs()
751 } else if (!strcmp(lopt, "pretimeout-action")) { in parseargs()
754 } else if (!strcmp(lopt, "softtimeout-action")) { in parseargs()
774 if (carp_thresh_seconds == -1) in parseargs()
779 if (is_daemon && timeout < WD_TO_1SEC) in parseargs()
780 errx(EX_USAGE, "-t argument is less than one second."); in parseargs()
784 "pretimeout (%d) >= timeout (%d -> %ld)\n" in parseargs()
785 "see manual section TIMEOUT RESOLUTION", in parseargs()