diff options
Diffstat (limited to 'miscutils/watchdog.c')
-rw-r--r-- | miscutils/watchdog.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index e3d77d1..28ae9bd 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c @@ -29,29 +29,21 @@ int watchdog_main(int argc, char **argv) unsigned timer_duration = 30; /* Userspace timer duration, in seconds */ char *t_arg; + opt_complementary = "=1"; /* must have 1 argument */ opts = getopt32(argc, argv, "Ft:", &t_arg); if (opts & OPT_TIMER) timer_duration = xatou(t_arg); - /* We're only interested in the watchdog device .. */ - if (optind < argc - 1 || argc == 1) - bb_show_usage(); - if (!(opts & OPT_FOREGROUND)) { -#ifdef BB_NOMMU - if (!re_execed) - vfork_daemon_rexec(0, 1, argv); -#else - xdaemon(0, 1); -#endif + bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); } signal(SIGHUP, watchdog_shutdown); signal(SIGINT, watchdog_shutdown); /* Use known fd # - avoid needing global 'int fd' */ - dup2(xopen(argv[argc - 1], O_WRONLY), 3); + xmove_fd(xopen(argv[argc - 1], O_WRONLY), 3); while (1) { /* @@ -63,6 +55,5 @@ int watchdog_main(int argc, char **argv) } watchdog_shutdown(0); - /* return EXIT_SUCCESS; */ } |