From 1f8ca6302d4c08a9c26337183186258d2ed79906 Mon Sep 17 00:00:00 2001 From: scottmk Date: Fri, 7 May 2010 20:18:36 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1955 9efc2488-bf62-4759-914b-345cdb29e865 --- include/opensrf/utils.h | 1 - src/libopensrf/utils.c | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/include/opensrf/utils.h b/include/opensrf/utils.h index 112c7ee..2f9c786 100644 --- a/include/opensrf/utils.h +++ b/include/opensrf/utils.h @@ -281,7 +281,6 @@ int init_proc_title( int argc, char* argv[] ); 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); diff --git a/src/libopensrf/utils.c b/src/libopensrf/utils.c index bd48953..52e8a68 100644 --- a/src/libopensrf/utils.c +++ b/src/libopensrf/utils.c @@ -651,18 +651,6 @@ char* uescape( const char* string, int size, int full_escape ) { 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 @@ int daemonize_write_pid( FILE* pidfile ) { return 0; } else { // We're in the parent... - if( pidfile ) { - fprintf( pidfile, "%ld\n", (long) f ); - fclose( pidfile ); - } _exit(0); } } -- 2.43.2