- if ((fd=open(argv[1], O_WRONLY)) == -1) {
- perror_msg_and_die(argv[1]);
- }
+ /* We're only interested in the watchdog device .. */
+ if (optind < argc - 1 || argc == 1)
+ bb_show_usage();
+
+ if (daemon(0, 1) < 0)
+ bb_perror_msg_and_die("Failed forking watchdog daemon");
+
+ signal(SIGHUP, watchdog_shutdown);
+ signal(SIGINT, watchdog_shutdown);
+
+ fd = bb_xopen(argv[argc - 1], O_WRONLY);