diff -urpN source/lib/debug.c source.fix/lib/debug.c --- source/lib/debug.c Thu Aug 12 21:24:24 2004 +++ source.fix/lib/debug.c Tue Oct 5 15:11:51 2004 @@ -290,6 +290,11 @@ void setup_logging(const char *pname, BO if (interactive) { stdout_logging = True; dbf = stdout; + /* switch stdout into unbuffered mode */ + setvbuf(stdout,NULL,_IONBF,256); + /* FIXME: why stdout?! stderr seems more appropriate - + ** it would work even for inetd-style usage. + */ } #ifdef WITH_SYSLOG else { diff -urpN source/nmbd/nmbd.c source.fix/nmbd/nmbd.c --- source/nmbd/nmbd.c Thu Aug 12 21:24:28 2004 +++ source.fix/nmbd/nmbd.c Tue Oct 5 12:17:23 2004 @@ -649,6 +649,7 @@ static void usage(char *pname) printf( "\t-D Become a daemon (default)\n" ); printf( "\t-a Append to log file (default)\n" ); printf( "\t-i Run interactive (not a daemon)\n" ); + printf( "\t-f Foreground (same as -i)\n" ); printf( "\t-o Overwrite log file, don't append\n" ); printf( "\t-h Print usage\n" ); printf( "\t-V Print version\n" ); @@ -726,7 +727,7 @@ static void usage(char *pname) #endif while( EOF != - (opt = getopt( argc, argv, "Vaos:T:I:C:bAB:N:Rn:l:d:Dip:hSH:G:f:" )) ) + (opt = getopt( argc, argv, "Vaos:T:I:C:bAB:N:Rn:l:d:Difp:hSH:G:" )) ) { switch (opt) { @@ -758,6 +759,7 @@ static void usage(char *pname) append_log = False; break; case 'i': + case 'f': opt_interactive = True; break; case 'D': @@ -836,7 +838,7 @@ static void usage(char *pname) #if HAVE_SETPGID /* - * If we're interactive we want to set our own process group for + * If we're interactive/foreground we want to set our own process group for * signal management. */ if (opt_interactive) diff -urpN source/nsswitch/winbindd.c source.fix/nsswitch/winbindd.c --- source/nsswitch/winbindd.c Thu Aug 12 21:24:23 2004 +++ source.fix/nsswitch/winbindd.c Tue Oct 5 12:17:57 2004 @@ -728,6 +728,7 @@ static void usage(void) printf("Usage: winbindd [options]\n"); printf("Version: %s\n", VERSION); printf("\t-i interactive mode\n"); + printf("\t-f foreground mode (same as -i)\n"); printf("\t-n disable cacheing\n"); printf("\t-d level set debug level\n"); printf("\t-s configfile choose smb.conf location\n"); @@ -768,11 +769,12 @@ int main(int argc, char **argv) /* Initialise samba/rpc client stuff */ - while ((opt = getopt(argc, argv, "id:s:nh")) != EOF) { + while ((opt = getopt(argc, argv, "ifd:s:nh")) != EOF) { switch (opt) { /* Don't become a daemon */ case 'i': + case 'f': interactive = True; break; diff -urpN source/smbd/server.c source.fix/smbd/server.c --- source/smbd/server.c Thu Aug 12 21:24:21 2004 +++ source.fix/smbd/server.c Tue Oct 5 15:00:02 2004 @@ -620,7 +620,8 @@ static void usage(char *pname) printf(" [-O socket options] [-s services file]\n"); printf("\t-D Become a daemon (default)\n"); printf("\t-a Append to log file (default)\n"); - printf("\t-i Run interactive (not a daemon)\n"); + printf("\t-i Run interactive (not a daemon, single thread only)\n"); + printf("\t-f Foreground (do not reparent to init)\n" ); printf("\t-o Overwrite log file, don't append\n"); printf("\t-h Print usage\n"); printf("\t-? Print usage\n"); @@ -644,6 +645,7 @@ static void usage(char *pname) /* shall I run as a daemon */ BOOL is_daemon = False; BOOL interactive = False; + BOOL foreground = False; BOOL specified_logfile = False; int port = SMB_PORT; int opt; @@ -660,7 +662,7 @@ static void usage(char *pname) argc--; } - while ( EOF != (opt = getopt(argc, argv, "O:l:s:d:Dip:h?Vaof:")) ) + while ( EOF != (opt = getopt(argc, argv, "O:l:s:d:Difp:h?Vao:")) ) switch (opt) { case 'O': pstrcpy(user_socket_options,optarg); @@ -692,6 +694,10 @@ static void usage(char *pname) interactive = True; break; + case 'f': + foreground = True; + break; + case 'd': if (*optarg == 'A') DEBUGLEVEL = 10000; @@ -739,10 +745,10 @@ static void usage(char *pname) pstrcpy(remote_machine, "smbd"); /* - * Only want interactive behaviour if the user has not also + * Only want interactive/foreground behaviour if the user has not also * specified a logfile dir etc. */ - setup_logging(argv[0],interactive & !specified_logfile); + setup_logging(argv[0],(interactive||foreground) && !specified_logfile); charset_initialise(); @@ -831,8 +837,7 @@ static void usage(char *pname) DEBUG(3,( "loaded services\n")); if (!is_daemon && !is_a_socket(0)) { - if (!interactive) - DEBUG(0,("standard input is not a socket, assuming -D option\n")); + DEBUG(0,("standard input is not a socket, assuming -D option\n")); /* * Setting is_daemon here prevents us from eventually calling @@ -842,17 +847,17 @@ static void usage(char *pname) is_daemon = True; } - if (is_daemon && !interactive) { + if (is_daemon && !interactive && !foreground) { DEBUG( 3, ( "Becoming a daemon.\n" ) ); become_daemon(); } #if HAVE_SETPGID /* - * If we're interactive we want to set our own process group for - * signal management. + * If we're interactive/foreground we want to set our own + * process group for signal management. */ - if (interactive) + if (interactive||foreground) setpgid( (pid_t)0, (pid_t)0); #endif