aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/watchdog.c11
1 files changed, 9 insertions, 2 deletions
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 */
19static int fd; 22static int fd;
20 23
@@ -27,10 +30,13 @@ static void watchdog_shutdown(int ATTRIBUTE_UNUSED unused)
27 30
28int watchdog_main(int argc, char **argv) 31int 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