diff options
-rw-r--r-- | include/usage.h | 5 | ||||
-rw-r--r-- | miscutils/watchdog.c | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/include/usage.h b/include/usage.h index 712eede63..4aed1664d 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -3372,11 +3372,12 @@ USE_FEATURE_START_STOP_DAEMON_FANCY( \ | |||
3372 | "Mon Dec 17 10:31:44 GMT 2000" | 3372 | "Mon Dec 17 10:31:44 GMT 2000" |
3373 | 3373 | ||
3374 | #define watchdog_trivial_usage \ | 3374 | #define watchdog_trivial_usage \ |
3375 | "[-t <seconds>] DEV" | 3375 | "[-t <seconds>] [-F] DEV" |
3376 | #define watchdog_full_usage \ | 3376 | #define watchdog_full_usage \ |
3377 | "Periodically write to watchdog device DEV.\n" \ | 3377 | "Periodically write to watchdog device DEV.\n" \ |
3378 | "Options:\n" \ | 3378 | "Options:\n" \ |
3379 | "\t-t\tTimer period in seconds - default is 30" | 3379 | "\t-t\tTimer period in seconds - default is 30\n" \ |
3380 | "\t-F\tStay in the foreground and don't fork" | ||
3380 | 3381 | ||
3381 | #define wc_trivial_usage \ | 3382 | #define wc_trivial_usage \ |
3382 | "[OPTION]... [FILE]..." | 3383 | "[OPTION]... [FILE]..." |
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index e8275e68e..ddd349d9b 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
@@ -15,6 +15,9 @@ | |||
15 | #include <stdlib.h> | 15 | #include <stdlib.h> |
16 | #include <signal.h> | 16 | #include <signal.h> |
17 | 17 | ||
18 | #define OPT_FOREGROUND 0x01 | ||
19 | #define OPT_TIMER 0x02 | ||
20 | |||
18 | /* Watchdog file descriptor */ | 21 | /* Watchdog file descriptor */ |
19 | static int fd; | 22 | static int fd; |
20 | 23 | ||
@@ -27,10 +30,13 @@ static void watchdog_shutdown(int ATTRIBUTE_UNUSED unused) | |||
27 | 30 | ||
28 | int watchdog_main(int argc, char **argv) | 31 | int watchdog_main(int argc, char **argv) |
29 | { | 32 | { |
33 | unsigned long opts; | ||
30 | unsigned long timer_duration = 30; /* Userspace timer duration, in seconds */ | 34 | unsigned long timer_duration = 30; /* Userspace timer duration, in seconds */ |
31 | char *t_arg; | 35 | char *t_arg; |
32 | 36 | ||
33 | if (bb_getopt_ulflags(argc, argv, "t:", &t_arg)) | 37 | opts = bb_getopt_ulflags(argc, argv, "Ft:", &t_arg); |
38 | |||
39 | if (opts & OPT_TIMER) | ||
34 | timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX); | 40 | timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX); |
35 | 41 | ||
36 | /* We're only interested in the watchdog device .. */ | 42 | /* We're only interested in the watchdog device .. */ |
@@ -38,7 +44,8 @@ int watchdog_main(int argc, char **argv) | |||
38 | bb_show_usage(); | 44 | bb_show_usage(); |
39 | 45 | ||
40 | #ifdef BB_NOMMU | 46 | #ifdef BB_NOMMU |
41 | vfork_daemon(0, 1); | 47 | if (!(opts & OPT_FOREGROUND)) |
48 | vfork_daemon_rexec(0, 1, argc, argv, "-F"); | ||
42 | #else | 49 | #else |
43 | bb_xdaemon(0, 1); | 50 | bb_xdaemon(0, 1); |
44 | #endif | 51 | #endif |