Lines Matching +full:reset +full:- +full:time +full:- +full:sec
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2003-2004 Sean M. Kelly <smkelly@FreeBSD.org>
41 #include <sys/time.h>
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()
193 ts->tv_sec = ns / 1000000000ULL; in pow2ns_to_ts()
194 ts->tv_nsec = ns % 1000000000ULL; in pow2ns_to_ts()
211 char shortopt[] = "- "; 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()
269 * If we are doing timing, then get the time.
292 int sec; in watchdog_check_dogfunction_time() local
300 sec = tv.tv_sec; in watchdog_check_dogfunction_time()
301 if (sec < carp_thresh_seconds) in watchdog_check_dogfunction_time()
302 return (sec); 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()
324 * amount of time to run. in watchdog_check_dogfunction_time()
327 return (sec); in watchdog_check_dogfunction_time()
330 sec = tv.tv_sec; in watchdog_check_dogfunction_time()
332 return (sec); in watchdog_check_dogfunction_time()
370 if (nap - waited > 0) in watchdog_loop()
371 sleep(nap - waited); in watchdog_loop()
386 * Reset the watchdog timer. This function must be called periodically
454 /* pat one more time for good measure */ 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()
587 register long sec, usec; in tvtohz() local
602 * If the number of usecs in the whole seconds part of the time in tvtohz()
610 * the time difference fits in a long, then convert the parts to in tvtohz()
615 * Otherwise, round the time difference down to the maximum in tvtohz()
621 sec = tv->tv_sec; in tvtohz()
622 usec = tv->tv_usec; in tvtohz()
624 sec--; in tvtohz()
627 if (sec < 0) { in tvtohz()
630 sec++; in tvtohz()
631 usec -= 1000000; in tvtohz()
633 printf("tvotohz: negative time difference %ld sec %ld usec\n", in tvtohz()
634 sec, usec); in tvtohz()
637 } else if (sec <= LONG_MAX / 1000000) in tvtohz()
638 ticks = (sec * 1000000 + (unsigned long)usec + (tick - 1)) in tvtohz()
640 else if (sec <= LONG_MAX / hz) in tvtohz()
641 ticks = sec * hz in tvtohz()
642 + ((unsigned long)usec + (tick - 1)) / tick + 1; in tvtohz()
694 if (argv[0][c - 1] == 'd') in parseargs()
703 &longindex)) != -1) { 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()
780 errx(EX_USAGE, "-t argument is less than one second."); in parseargs()
784 "pretimeout (%d) >= timeout (%d -> %ld)\n" in parseargs()