]>
Commit | Line | Data |
---|---|---|
d6d320e9 JK |
1 | diff -dur -x '*~' watchdog-5.2.4.orig.orig/src/watchdog.c watchdog-5.2.4.orig/src/watchdog.c |
2 | --- watchdog-5.2.4.orig.orig/src/watchdog.c 2003-07-08 14:34:19.000000000 +0200 | |
3 | +++ watchdog-5.2.4.orig/src/watchdog.c 2005-06-04 17:07:36.000000000 +0200 | |
4 | @@ -85,9 +85,9 @@ | |
5 | { | |
6 | fprintf(stderr, "%s version %d.%d, usage:\n", progname, MAJOR_VERSION, MINOR_VERSION); | |
7 | #if USE_SYSLOG | |
8 | - fprintf(stderr, "%s [-i <interval> [-f]] [-l <max load avg>] [-v] [-s] [-b] [-m <max temperature>]\n", progname); | |
9 | + fprintf(stderr, "%s [-i <interval> [-f]] [-l <max load avg>] [-v] [-s] [-b] [-m <max temperature>] [-F]\n", progname); | |
10 | #else /* USE_SYSLOG */ | |
11 | - fprintf(stderr, "%s [-i <interval> [-f]] [-l <max load avg>] [-v] [-b] [-m <max temperature>]\n", progname); | |
12 | + fprintf(stderr, "%s [-i <interval> [-f]] [-l <max load avg>] [-v] [-b] [-m <max temperature>] [-F]\n", progname); | |
13 | #endif /* USE_SYSLOG */ | |
14 | exit(1); | |
15 | } | |
16 | @@ -424,14 +424,14 @@ | |
17 | int main(int argc, char *const argv[]) | |
18 | { | |
19 | FILE *fp; | |
20 | - int c, force = FALSE, sync_it = FALSE; | |
21 | + int c, force = FALSE, sync_it = FALSE, foreground = FALSE; | |
22 | int hold; | |
23 | char *filename = CONFIG_FILENAME; | |
24 | struct list *act; | |
25 | pid_t child_pid; | |
26 | ||
27 | #if USE_SYSLOG | |
28 | - char *opts = "d:i:n:fsvbql:p:t:c:r:m:a:"; | |
29 | + char *opts = "d:i:n:fsvbql:p:t:c:r:m:a:F"; | |
30 | struct option long_options[] = | |
31 | { | |
32 | {"config-file", required_argument, NULL, 'c'}, | |
33 | @@ -440,11 +440,12 @@ | |
34 | {"no-action", no_argument, NULL, 'q'}, | |
35 | {"verbose", no_argument, NULL, 'v'}, | |
36 | {"softboot", no_argument, NULL, 'b'}, | |
37 | + {"foreground", no_argument, NULL, 'F'}, | |
38 | {NULL, 0, NULL, 0} | |
39 | }; | |
40 | long count = 0L; | |
41 | #else /* USE_SYSLOG */ | |
42 | - char *opts = "d:i:n:fsbql:p:t:c:r:m:a:"; | |
43 | + char *opts = "d:i:n:fsbql:p:t:c:r:m:a:F"; | |
44 | struct option long_options[] = | |
45 | { | |
46 | {"config-file", required_argument, NULL, 'c'}, | |
47 | @@ -452,6 +453,7 @@ | |
48 | {"sync", no_argument, NULL, 's'}, | |
49 | {"no-action", no_argument, NULL, 'q'}, | |
50 | {"softboot", no_argument, NULL, 'b'}, | |
51 | + {"foreground", no_argument, NULL, 'F'}, | |
52 | {NULL, 0, NULL, 0} | |
53 | }; | |
54 | #endif /* USE_SYSLOG */ | |
55 | @@ -496,6 +498,9 @@ | |
56 | verbose = TRUE; | |
57 | break; | |
58 | #endif /* USE_SYSLOG */ | |
59 | + case 'F': | |
60 | + foreground = TRUE; | |
61 | + break; | |
62 | default: | |
63 | usage(); | |
64 | } | |
65 | @@ -575,40 +580,44 @@ | |
66 | exit(1); | |
67 | } | |
68 | #if !defined(DEBUG) | |
69 | - /* fork to go into the background */ | |
70 | - if ((child_pid = fork()) < 0) { | |
71 | - perror(progname); | |
72 | - exit(1); | |
73 | - } else if (child_pid > 0) { | |
74 | - /* fork was okay */ | |
75 | - /* wait for child to exit */ | |
76 | - if (waitpid(child_pid, NULL, 0) != child_pid) { | |
77 | + if (!foreground) { | |
78 | + /* fork to go into the background */ | |
79 | + if ((child_pid = fork()) < 0) { | |
80 | perror(progname); | |
81 | exit(1); | |
82 | + } else if (child_pid > 0) { | |
83 | + /* fork was okay */ | |
84 | + /* wait for child to exit */ | |
85 | + if (waitpid(child_pid, NULL, 0) != child_pid) { | |
86 | + perror(progname); | |
87 | + exit(1); | |
88 | + } | |
89 | + /* and exit myself */ | |
90 | + exit(0); | |
91 | } | |
92 | - /* and exit myself */ | |
93 | - exit(0); | |
94 | + /* and fork again to make sure we inherit all rights from init */ | |
95 | + if ((child_pid = fork()) < 0) { | |
96 | + perror(progname); | |
97 | + exit(1); | |
98 | + } else if (child_pid > 0) | |
99 | + exit(0); | |
100 | } | |
101 | - /* and fork again to make sure we inherit all rights from init */ | |
102 | - if ((child_pid = fork()) < 0) { | |
103 | - perror(progname); | |
104 | - exit(1); | |
105 | - } else if (child_pid > 0) | |
106 | - exit(0); | |
107 | #endif /* !DEBUG */ | |
108 | ||
109 | /* now we're free */ | |
110 | #if USE_SYSLOG | |
111 | #if !defined(DEBUG) | |
112 | - /* Okay, we're a daemon */ | |
113 | - /* but we're still attached to the tty */ | |
114 | - /* create our own session */ | |
115 | - setsid(); | |
116 | + if (!foreground) { | |
117 | + /* Okay, we're a daemon */ | |
118 | + /* but we're still attached to the tty */ | |
119 | + /* create our own session */ | |
120 | + setsid(); | |
121 | ||
122 | - /* with USE_SYSLOG we don't do any console IO */ | |
123 | - close(0); | |
124 | - close(1); | |
125 | - close(2); | |
126 | + /* with USE_SYSLOG we don't do any console IO */ | |
127 | + close(0); | |
128 | + close(1); | |
129 | + close(2); | |
130 | + } | |
131 | #endif /* !DEBUG */ | |
132 | ||
133 | /* Log the starting message */ | |
134 | @@ -763,6 +772,7 @@ | |
135 | /* set signal term to call terminate() */ | |
136 | /* to make sure watchdog device is closed */ | |
137 | signal(SIGTERM, terminate); | |
138 | + signal(SIGINT, terminate); | |
139 | ||
140 | #if defined(_POSIX_MEMLOCK) | |
141 | if (realtime == TRUE) { | |
142 | diff -dur -x '*~' watchdog-5.2.4.orig.orig/watchdog.8 watchdog-5.2.4.orig/watchdog.8 | |
143 | --- watchdog-5.2.4.orig.orig/watchdog.8 1999-12-20 12:19:58.000000000 +0100 | |
144 | +++ watchdog-5.2.4.orig/watchdog.8 2005-06-04 17:07:01.000000000 +0200 | |
145 | @@ -16,6 +16,8 @@ | |
146 | .I -b | --softboot | |
147 | ] [ | |
148 | .I -q | --no-action | |
149 | +] [ | |
150 | +.I -F | --foreground | |
151 | ] | |
152 | .br | |
153 | .SH DESCRIPTION | |
154 | @@ -94,9 +96,14 @@ | |
155 | Also your hardware card resp. the kernel software watchdog driver is not | |
156 | enabled. Note that temperature checking is also disabled since this triggers | |
157 | the hardware watchdog on some cards. | |
158 | +.TP | |
159 | +-F | --foreground | |
160 | +Do not fork into the background and do not detach from the terminal. | |
161 | .LP | |
162 | .SH FUNCTION | |
163 | -Watchdog starts, put itself into the background and then try all checks | |
164 | +Watchdog starts, put itself into the background (unless | |
165 | +.I -F | |
166 | +option is given) and then try all checks | |
167 | specified in its config file in turn. Between each two tests it will trigger | |
168 | the kernel device. After finishing all tests watchdog goes to sleep for some | |
169 | time. The kernel drivers expects a write to the watchdog device every minute. |