- opt = getopt32(argc, argv, "fiwb:", &bind_address);
- if (optind < argc)
- bogouser = argv[optind];
-
- /* Daemonize if no -f or -i or -w */
- bb_sanitize_stdio(!(opt & OPT_nodeamon));
- if (!(opt & OPT_nodeamon)) {
+ opt = getopt32(argv, "fiwb:", &bind_address);
+ strcpy(bogouser, "nobody");
+ if (argv[optind])
+ strncpy(bogouser, argv[optind], sizeof(bogouser));
+
+ /* Daemonize if no -f and no -i and no -w */
+ if (!(opt & OPT_fiw));
+ bb_daemonize_or_rexec(0, argv);
+
+ /* Where to log in inetd modes? "Classic" inetd
+ * probably has its stderr /dev/null'ed (we need log to syslog?),
+ * but daemontools-like utilities usually expect that children
+ * log to stderr. I like daemontools more. Go their way.
+ * (Or maybe we need yet another option "log to syslog") */
+ if (!(opt & OPT_fiw) /* || (opt & OPT_syslog) */) {