diff -rup ./inetd/inetd.c ../inetutils-1.3.2-32-mod/inetd/inetd.c --- ./inetd/inetd.c 2004-04-07 14:29:06.000000000 -0500 +++ ../inetutils-1.3.2-32-mod/inetd/inetd.c 2006-01-10 18:16:00.275868000 -0600 @@ -145,6 +145,7 @@ static char sccsid[] = "@(#)inetd.c 8.4 int debug = 0; +int daemonize = 1; int nsock, maxsock; fd_set allsock; int options; @@ -548,6 +549,7 @@ error: struct option longopts[] = { { "debug", no_argument, NULL, 'd' }, + { "no-daemonize", no_argument, NULL, 'D' }, { "invocation-rate", required_argument, NULL, 'R' }, { "install-as-service", no_argument, NULL, 'i' }, { "remove-as-service", no_argument, NULL, 'r' }, @@ -652,7 +654,7 @@ service_main(argc, argv) if (is_winnt) hide_console (); - if (is_winnt && !debug) { + if (is_winnt && daemonize && !debug) { openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON); if (! (ssh = RegisterServiceCtrlHandlerA(INETD_SERVICE_NAME, @@ -897,7 +899,7 @@ service_main(argc, argv) sigsetmask(0L); #endif if (pid == 0) { - if (debug && dofork) + if ((debug || !daemonize) && dofork) setsid(); if (dofork) { if (debug) @@ -971,7 +973,7 @@ main(argc, argv, envp) #ifdef __CYGWIN__ int install = 0; int remove = 0; - char *opts = is_winnt ? "dR:ir" : "dR:"; + char *opts = is_winnt ? "dDR:ir" : "dDR:"; #endif /* __CYGWIN__ */ (void) close(0); @@ -1007,6 +1009,9 @@ main(argc, argv, envp) toomany = tmpint; break; } + case 'D': /* don't become a daemon */ + daemonize = 0; + break; #ifdef __CYGWIN__ case 'i': /* install-as-service */ install = 1; @@ -1020,10 +1025,10 @@ main(argc, argv, envp) #ifdef __CYGWIN__ syslog(LOG_ERR, "\nusage:" - "\ninetd [-d] [-R rate] [conf-file]" - "\ninetd --install-as-service [-d]" - "[-R rate] [conf-file]" - "\ninetd --remove-as-service [-d]"); + "\ninetd [-d] [-D] [-R rate] [conf-file]" + "\ninetd --install-as-service [-d] " + "[-D] [-R rate] [conf-file]" + "\ninetd --remove-as-service [-d] [-D]"); #else syslog(LOG_ERR, "usage: inetd [-d] [-R rate] [conf-file]"); @@ -1054,12 +1059,12 @@ main(argc, argv, envp) return 0; } } - if (argc > 0 && ! debug) + if (argc > 0 && !debug && daemonize) syslog(LOG_NOTICE, "additional arguments ignored"); #endif /* __CYGWIN__ */ if (argc > 0) CONFIG = argv[0]; - if (debug == 0) { + if (debug == 0 && daemonize) { #ifdef __CYGWIN__ if (is_winnt) { SERVICE_TABLE_ENTRYA ste[2];