Mercurial > vordog
annotate vd_watchdog/vd_watchdog.c @ 1:0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 08 Jul 2008 11:07:31 +0800 |
parents | 71475f5afa92 |
children | 89e9d591748d |
rev | line source |
---|---|
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #include <stdio.h> |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #include <stdlib.h> |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 #include <unistd.h> |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include <fcntl.h> |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 #include <sys/ioctl.h> |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
6 #include <sys/types.h> |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 #include "vordog.h" |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 #define DEVNAME "/dev/vordog0" |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 #define PROG "vd_watchdog" |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
12 static int unit_factors[] = {0, 1, 60, 3600}; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
13 |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 static void |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
15 watchdog(int timeout, int unit) { |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 struct vordog_cfg cfg; |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 int intval; |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 int r; |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 int fd; |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 fd = open(DEVNAME, O_RDWR); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 if(fd == -1) { |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 perror(PROG); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 exit(1); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
25 } |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
26 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
27 cfg.init_val = timeout; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
28 cfg.unit = unit; |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 r = ioctl(fd, VDCTL_ENABLE, &cfg); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 if(r == -1) { |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 perror(PROG); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 exit(1); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 } |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
34 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
35 /* reset timer periodically */ |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
36 intval = timeout * unit_factors[unit]; |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 while(1) { |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 sleep(intval); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 r = ioctl(fd, VDCTL_RESET); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 if(r == -1) { |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 perror(PROG); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 exit(1); |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 } |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
44 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
45 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
46 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
47 static void |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
48 daemonize(void) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
49 pid_t pid; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
50 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
51 pid = fork(); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
52 if(pid == -1) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
53 perror("fork"); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
54 exit(1); |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 } |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
56 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
57 if(pid != 0) |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
58 exit(0); /* parent */ |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
59 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
60 /* child process */ |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
61 pid = setsid(); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
62 if(pid == -1) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
63 perror("setsid"); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
64 exit(1); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
65 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
66 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
67 close(STDOUT_FILENO); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
68 close(STDOUT_FILENO); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
69 /* close(STDERR_FILENO); */ |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
70 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
71 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
72 static void |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
73 usage(const char *prog) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
74 fprintf(stderr, "Usage: %s [-msMH] <timeout>\n"); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
75 fprintf(stderr, "\t-s\tcount in seconds.\n"); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
76 fprintf(stderr, "\t-M\tcount in minutes.\n"); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
77 fprintf(stderr, "\t-m\tcount in hours.\n"); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
78 fprintf(stderr, |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
79 "\t<timeout> is interval between periodically reset of\n" |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
80 "\t\twatchdog timer, or the system would be reseted without\n" |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
81 "\t\treseting timer for 4 times. (default: 30s)\n" |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
82 "\t\t(note: 1~255)\n"); |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
83 } |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
84 |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
85 |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
86 static char *unit_names[] = { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
87 "* 4ms", |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
88 "seconds", |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
89 "minutes", |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
90 "hours" |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
91 }; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
92 |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
93 int |
1
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
94 main(int argc, char * const argv[]) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
95 int timeout, unit; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
96 int ch; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
97 const char *prog = argv[0]; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
98 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
99 timeout = 30; /* default: 30s */ |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
100 unit = VDT_1S; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
101 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
102 while((ch = getopt(argc, argv, "")) != -1) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
103 switch(ch) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
104 case 's': |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
105 unit = VDT_1S; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
106 break; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
107 case 'M': |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
108 unit = VDT_1M; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
109 break; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
110 case 'H': |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
111 unit = VDT_1H; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
112 break; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
113 case '?': |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
114 default: |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
115 usage(prog); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
116 exit(1); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
117 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
118 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
119 argc -= optind; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
120 argv += optind; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
121 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
122 if(argc != 1 && argc != 0) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
123 usage(prog); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
124 return 1; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
125 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
126 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
127 if(argc == 1) |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
128 timeout = atoi(argv[0]); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
129 if(timeout < 1 || timeout > 255) { |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
130 usage(prog); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
131 return 1; |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
132 } |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
133 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
134 printf("Reset watchdog timer every %d %s\n", |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
135 timeout, unit_names[unit]); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
136 |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
137 daemonize(); |
0b9854adb86c
Remove tedious messages and daemonize vd_watchdog.
Thinker K.F. Li <thinker@branda.to>
parents:
0
diff
changeset
|
138 watchdog(timeout, unit); |
0
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
139 return 0; |
71475f5afa92
Watchdog for Vortex86 6071 on FreeBSD
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
140 } |