gnome-keyring r1593 - in trunk: . daemon



Author: nnielsen
Date: Sat Feb 14 22:45:25 2009
New Revision: 1593
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1593&view=rev

Log:
Close stdin/stdout when not running in foreground.

Fixes bug #571781

Modified:
   trunk/ChangeLog
   trunk/daemon/gkr-daemon.c

Modified: trunk/daemon/gkr-daemon.c
==============================================================================
--- trunk/daemon/gkr-daemon.c	(original)
+++ trunk/daemon/gkr-daemon.c	Sat Feb 14 22:45:25 2009
@@ -579,31 +579,32 @@
 		exit (0);
 	}
 	
-	if (!run_daemonized) 
-		return;
-	
-	/* Double fork if need to daemonize properly */
-	pid = fork ();
-	
-	if (pid != 0) {
-
-		/* Here we are in the intermediate child process */
-			
-		/* 
-		 * This process exits, so that the final child will inherit 
-		 * init as parent to avoid zombies
-		 */
-		if (pid == -1)
-			exit (1);
-
-		/* We've done two forks. Now we know the PID */
-		print_environment (pid);
-			
-		/* The intermediate child exits */
-		exit (0);
+	if (run_daemonized) { 
+		
+		/* Double fork if need to daemonize properly */
+		pid = fork ();
+	
+		if (pid != 0) {
+
+			/* Here we are in the intermediate child process */
+				
+			/* 
+			 * This process exits, so that the final child will inherit 
+			 * init as parent to avoid zombies
+			 */
+			if (pid == -1)
+				exit (1);
+	
+			/* We've done two forks. Now we know the PID */
+			print_environment (pid);
+				
+			/* The intermediate child exits */
+			exit (0);
+		}
+		
 	}
 
-	/* Here we are in the resulting daemon process. */
+	/* Here we are in the resulting daemon or background process. */
 
 	for (i = 0; i < 3; ++i) {
 		fd = open ("/dev/null", O_RDONLY);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]