[Opensrf-commits] r1955 - in trunk: include/opensrf src/libopensrf (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri May 7 16:18:42 EDT 2010


Author: scottmk
Date: 2010-05-07 16:18:36 -0400 (Fri, 07 May 2010)
New Revision: 1955

Modified:
   trunk/include/opensrf/utils.h
   trunk/src/libopensrf/utils.c
Log:
Eliminate the daemonize_write_pid function (thereby reverting a
previous change).

It works better, and is less convoluted, to write the PID file from
the child process instead of from the parent process.

M    include/opensrf/utils.h
M    src/libopensrf/utils.c


Modified: trunk/include/opensrf/utils.h
===================================================================
--- trunk/include/opensrf/utils.h	2010-05-07 16:40:35 UTC (rev 1954)
+++ trunk/include/opensrf/utils.h	2010-05-07 20:18:36 UTC (rev 1955)
@@ -281,7 +281,6 @@
 int set_proc_title( const char* format, ... );
 
 int daemonize( void );
-int daemonize_write_pid( FILE* pidfile );
 
 void* safe_malloc(int size);
 void* safe_calloc(int size);

Modified: trunk/src/libopensrf/utils.c
===================================================================
--- trunk/src/libopensrf/utils.c	2010-05-07 16:40:35 UTC (rev 1954)
+++ trunk/src/libopensrf/utils.c	2010-05-07 20:18:36 UTC (rev 1955)
@@ -651,18 +651,6 @@
 	the terminal, and redirects the standard streams (stdin, stdout, stderr) to /dev/null.
 */
 int daemonize( void ) {
-	return daemonize_write_pid( NULL );
-}
-/**
-	@brief Become a proper daemon, and report the childs process ID.
-	@return 0 if successful, or -1 if not.
-
-	Call fork().  If pidfile is not NULL, the parent writes the process ID of the child
-	process to the specified file.  Then it exits.  The child moves to the root
-	directory, detaches from the terminal, and redirects the standard streams (stdin,
-	stdout, stderr) to /dev/null.
- */
-int daemonize_write_pid( FILE* pidfile ) {
 	pid_t f = fork();
 
 	if (f == -1) {
@@ -688,10 +676,6 @@
 		return 0;
 
 	} else { // We're in the parent...
-		if( pidfile ) {
-			fprintf( pidfile, "%ld\n", (long) f );
-			fclose( pidfile );
-		}
 		_exit(0);
 	}
 }



More information about the opensrf-commits mailing list