From: Pierangelo Masarati Date: Wed, 7 Dec 2005 14:47:00 +0000 (+0000) Subject: unlink pid/args files only if actually touched (ITS#4251) X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~626 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a4f800413d57145eaebc1bc79333bf8091518320;p=openldap unlink pid/args files only if actually touched (ITS#4251) --- diff --git a/servers/slapd/main.c b/servers/slapd/main.c index a24c0d8fe2..4011540a36 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -247,23 +247,25 @@ int main( int argc, char **argv ) char *sandbox = NULL; #endif #ifdef LOG_LOCAL4 - int syslogUser = DEFAULT_SYSLOG_USER; + int syslogUser = DEFAULT_SYSLOG_USER; #endif int g_argc = argc; char **g_argv = argv; - char *configfile = NULL; - char *configdir = NULL; - char *serverName; - int serverMode = SLAP_SERVER_MODE; + char *configfile = NULL; + char *configdir = NULL; + char *serverName; + int serverMode = SLAP_SERVER_MODE; struct sync_cookie *scp = NULL; struct sync_cookie *scp_entry = NULL; - char *serverNamePrefix = ""; + char *serverNamePrefix = ""; size_t l; + int slapd_pid_file_unlink = 0, slapd_args_file_unlink = 0; + #ifdef CSRIMALLOC FILE *leakfile; if( ( leakfile = fopen( "slapd.leak", "w" )) == NULL ) { @@ -749,9 +751,9 @@ unhandled_option:; rc = 1; goto destroy; } - fprintf( fp, "%d\n", (int) getpid() ); fclose( fp ); + slapd_pid_file_unlink = 1; } if ( slapd_args_file != NULL ) { @@ -777,6 +779,7 @@ unhandled_option:; } fprintf( fp, "\n" ); fclose( fp ); + slapd_args_file_unlink = 1; } /* @@ -859,10 +862,10 @@ stop: ldap_pvt_tls_destroy(); #endif - if ( slapd_pid_file != NULL ) { + if ( slapd_pid_file_unlink ) { unlink( slapd_pid_file ); } - if ( slapd_args_file != NULL ) { + if ( slapd_args_file_unlink ) { unlink( slapd_args_file ); }