svn commit: samba r14618 - in branches/SAMBA_3_0/source: lib nmbd nsswitch smbd web

metze at samba.org metze at samba.org
Tue Mar 21 13:16:51 GMT 2006


Author: metze
Date: 2006-03-21 13:16:50 +0000 (Tue, 21 Mar 2006)
New Revision: 14618

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14618

Log:
add --no-process-group to all server programms
to make the following possible:

timelimit 20000 bin/nmbd -F -S --no-process-group
timelimit 20000 bin/smbd -F -S --no-process-group

this is needed to 'make test' working without losing child processes

metze
Modified:
   branches/SAMBA_3_0/source/lib/util.c
   branches/SAMBA_3_0/source/nmbd/nmbd.c
   branches/SAMBA_3_0/source/nsswitch/winbindd.c
   branches/SAMBA_3_0/source/smbd/server.c
   branches/SAMBA_3_0/source/web/startstop.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/util.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util.c	2006-03-21 12:32:12 UTC (rev 14617)
+++ branches/SAMBA_3_0/source/lib/util.c	2006-03-21 13:16:50 UTC (rev 14618)
@@ -823,7 +823,7 @@
  Become a daemon, discarding the controlling terminal.
 ****************************************************************************/
 
-void become_daemon(BOOL Fork)
+void become_daemon(BOOL Fork, BOOL no_process_group)
 {
 	if (Fork) {
 		if (sys_fork()) {
@@ -833,9 +833,9 @@
 
   /* detach from the terminal */
 #ifdef HAVE_SETSID
-	setsid();
+	if (!no_process_group) setsid();
 #elif defined(TIOCNOTTY)
-	{
+	if (!no_process_group) {
 		int i = sys_open("/dev/tty", O_RDWR, 0);
 		if (i != -1) {
 			ioctl(i, (int) TIOCNOTTY, (char *)0);      

Modified: branches/SAMBA_3_0/source/nmbd/nmbd.c
===================================================================
--- branches/SAMBA_3_0/source/nmbd/nmbd.c	2006-03-21 12:32:12 UTC (rev 14617)
+++ branches/SAMBA_3_0/source/nmbd/nmbd.c	2006-03-21 13:16:50 UTC (rev 14618)
@@ -658,11 +658,13 @@
 	static BOOL opt_interactive;
 	poptContext pc;
 	static char *p_lmhosts = dyn_LMHOSTSFILE;
+	static BOOL no_process_group = False;
 	struct poptOption long_options[] = {
 	POPT_AUTOHELP
 	{"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon(default)" },
 	{"interactive", 'i', POPT_ARG_VAL, &opt_interactive, True, "Run interactive (not a daemon)" },
 	{"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools & etc)" },
+	{"no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
 	{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
 	{"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"},
 	{"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" },
@@ -749,7 +751,7 @@
   
 	if (is_daemon && !opt_interactive) {
 		DEBUG( 2, ( "Becoming a daemon.\n" ) );
-		become_daemon(Fork);
+		become_daemon(Fork, no_process_group);
 	}
 
 #if HAVE_SETPGID
@@ -757,7 +759,7 @@
 	 * If we're interactive we want to set our own process group for 
 	 * signal management.
 	 */
-	if (opt_interactive)
+	if (opt_interactive && !no_process_group)
 		setpgid( (pid_t)0, (pid_t)0 );
 #endif
 

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd.c	2006-03-21 12:32:12 UTC (rev 14617)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd.c	2006-03-21 13:16:50 UTC (rev 14618)
@@ -912,10 +912,12 @@
 	pstring logfile;
 	static BOOL Fork = True;
 	static BOOL log_stdout = False;
+	static BOOL no_process_group = False;
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
 		{ "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
 		{ "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" },
+		{ "no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
 		{ "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
 		{ "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, True, "Disable caching" },
 		POPT_COMMON_SAMBA
@@ -1036,7 +1038,7 @@
 	CatchSignal(SIGHUP, sighup_handler);
 
 	if (!interactive)
-		become_daemon(Fork);
+		become_daemon(Fork, no_process_group);
 
 	pidfile_create("winbindd");
 
@@ -1045,7 +1047,7 @@
 	 * If we're interactive we want to set our own process group for
 	 * signal management.
 	 */
-	if (interactive)
+	if (interactive && !no_process_group)
 		setpgid( (pid_t)0, (pid_t)0);
 #endif
 

Modified: branches/SAMBA_3_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/server.c	2006-03-21 12:32:12 UTC (rev 14617)
+++ branches/SAMBA_3_0/source/smbd/server.c	2006-03-21 13:16:50 UTC (rev 14618)
@@ -715,6 +715,7 @@
 	static BOOL is_daemon = False;
 	static BOOL interactive = False;
 	static BOOL Fork = True;
+	static BOOL no_process_group = False;
 	static BOOL log_stdout = False;
 	static char *ports = NULL;
 	int opt;
@@ -725,6 +726,7 @@
 	{"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon (default)" },
 	{"interactive", 'i', POPT_ARG_VAL, &interactive, True, "Run interactive (not a daemon)"},
 	{"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools & etc)" },
+	{"no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
 	{"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
 	{"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
 	{"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
@@ -865,7 +867,7 @@
 
 	if (is_daemon && !interactive) {
 		DEBUG( 3, ( "Becoming a daemon.\n" ) );
-		become_daemon(Fork);
+		become_daemon(Fork, no_process_group);
 	}
 
 #if HAVE_SETPGID
@@ -873,8 +875,9 @@
 	 * If we're interactive we want to set our own process group for
 	 * signal management.
 	 */
-	if (interactive)
+	if (interactive && !no_process_group) {
 		setpgid( (pid_t)0, (pid_t)0);
+	}
 #endif
 
 	if (!directory_exist(lp_lockdir(), NULL))

Modified: branches/SAMBA_3_0/source/web/startstop.c
===================================================================
--- branches/SAMBA_3_0/source/web/startstop.c	2006-03-21 12:32:12 UTC (rev 14617)
+++ branches/SAMBA_3_0/source/web/startstop.c	2006-03-21 13:16:50 UTC (rev 14618)
@@ -36,7 +36,7 @@
 
 	slprintf(binfile, sizeof(pstring) - 1, "%s/smbd", dyn_SBINDIR);
 
-	become_daemon(True);
+	become_daemon(True, False);
 
 	execl(binfile, binfile, "-D", NULL);
 
@@ -56,7 +56,7 @@
 
 	slprintf(binfile, sizeof(pstring) - 1, "%s/nmbd", dyn_SBINDIR);
 	
-	become_daemon(True);
+	become_daemon(True, False);
 
 	execl(binfile, binfile, "-D", NULL);
 
@@ -76,7 +76,7 @@
 
 	slprintf(binfile, sizeof(pstring) - 1, "%s/winbindd", dyn_SBINDIR);
 
-	become_daemon(True);
+	become_daemon(True, False);
 
 	execl(binfile, binfile, NULL);
 



More information about the samba-cvs mailing list