]>
Commit | Line | Data |
---|---|---|
123f3b3f | 1 | diff -urN ./watchdog-5.6.orig/src/watchdog.c ./watchdog-5.6/src/watchdog.c |
2 | --- ./watchdog-5.6.orig/src/watchdog.c 2009-03-22 13:52:24.000000000 +0100 | |
3 | +++ ./watchdog-5.6/src/watchdog.c 2009-05-30 10:12:58.000000000 +0200 | |
4 | @@ -94,9 +94,9 @@ | |
d6d320e9 JK |
5 | { |
6 | fprintf(stderr, "%s version %d.%d, usage:\n", progname, MAJOR_VERSION, MINOR_VERSION); | |
7 | #if USE_SYSLOG | |
123f3b3f | 8 | - fprintf(stderr, "%s [-f] [-c <config_file>] [-v] [-s] [-b] [-q]\n", progname); |
9 | + fprintf(stderr, "%s [-f] [-c <config_file>] [-v] [-s] [-b] [-q] [-F]\n", progname); | |
d6d320e9 | 10 | #else /* USE_SYSLOG */ |
123f3b3f | 11 | - fprintf(stderr, "%s [-f] [-c <config_file>] [-s] [-b] [-q]\n", progname); |
12 | + fprintf(stderr, "%s [-f] [-c <config_file>] [-s] [-b] [-q] [-F]\n", progname); | |
d6d320e9 JK |
13 | #endif /* USE_SYSLOG */ |
14 | exit(1); | |
15 | } | |
123f3b3f | 16 | @@ -441,14 +441,14 @@ |
d6d320e9 JK |
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'}, | |
123f3b3f | 33 | @@ -457,11 +457,12 @@ |
d6d320e9 JK |
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'}, | |
123f3b3f | 47 | @@ -469,6 +470,7 @@ |
d6d320e9 JK |
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 */ | |
123f3b3f | 55 | @@ -513,6 +515,9 @@ |
d6d320e9 JK |
56 | verbose = TRUE; |
57 | break; | |
58 | #endif /* USE_SYSLOG */ | |
59 | + case 'F': | |
60 | + foreground = TRUE; | |
61 | + break; | |
62 | default: | |
63 | usage(); | |
64 | } | |
123f3b3f | 65 | @@ -592,40 +597,44 @@ |
d6d320e9 JK |
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(); | |
123f3b3f | 116 | - |
d6d320e9 JK |
117 | - /* with USE_SYSLOG we don't do any console IO */ |
118 | - close(0); | |
119 | - close(1); | |
120 | - close(2); | |
123f3b3f | 121 | + if (!foreground) { |
122 | + /* Okay, we're a daemon */ | |
123 | + /* but we're still attached to the tty */ | |
124 | + /* create our own session */ | |
125 | + setsid(); | |
126 | + | |
127 | + /* with USE_SYSLOG we don't do any console IO */ | |
128 | + close(0); | |
129 | + close(1); | |
130 | + close(2); | |
d6d320e9 JK |
131 | + } |
132 | #endif /* !DEBUG */ | |
133 | ||
134 | /* Log the starting message */ | |
123f3b3f | 135 | @@ -794,6 +803,7 @@ |
136 | /* set signal term to set our run flag to 0 so that */ | |
137 | /* we make sure watchdog device is closed when receiving SIGTERM */ | |
138 | signal(SIGTERM, sigterm_handler); | |
d6d320e9 JK |
139 | + signal(SIGINT, terminate); |
140 | ||
141 | #if defined(_POSIX_MEMLOCK) | |
142 | if (realtime == TRUE) { | |
123f3b3f | 143 | diff -urN ./watchdog-5.6.orig/watchdog.8 ./watchdog-5.6/watchdog.8 |
144 | --- ./watchdog-5.6.orig/watchdog.8 2009-03-12 14:41:04.000000000 +0100 | |
145 | +++ ./watchdog-5.6/watchdog.8 2009-05-30 00:06:00.000000000 +0200 | |
e31059ed PG |
146 | @@ -10,6 +10,7 @@ |
147 | .RB [ \-s | \-\-sync ] | |
148 | .RB [ \-b | \-\-softboot ] | |
149 | .RB [ \-q | \-\-no\-action ] | |
150 | +.RB [ \-F | \-\-foreground ] | |
d6d320e9 | 151 | .SH DESCRIPTION |
e31059ed PG |
152 | The Linux kernel can reset the system if serious problems are detected. |
153 | This can be implemented via special watchdog hardware, or via a slightly | |
154 | @@ -107,10 +108,15 @@ | |
155 | Also your hardware card or the kernel software watchdog driver is not | |
156 | enabled. Temperature checking is also disabled since this triggers | |
d6d320e9 JK |
157 | the hardware watchdog on some cards. |
158 | +.TP | |
e31059ed | 159 | +.BR \-F ", "\-\-foreground |
d6d320e9 | 160 | +Do not fork into the background and do not detach from the terminal. |
d6d320e9 | 161 | .SH FUNCTION |
e31059ed PG |
162 | After |
163 | .B watchdog | |
164 | -starts, it puts itself into the background and then tries all checks | |
165 | +starts, it puts itself into the background (unless | |
d6d320e9 | 166 | +.I -F |
e31059ed PG |
167 | +option is given) and then tries all checks |
168 | specified in its configuration file in turn. Between each two tests it will write to | |
169 | the kernel device to prevent a reset. | |
170 | After finishing all tests watchdog goes to sleep for some |