From: Kurt Zeilenga Date: Wed, 19 Feb 2003 20:47:57 +0000 (+0000) Subject: ITS#2318: unlink pid file (and args file) X-Git-Tag: NO_SLAP_OP_BLOCKS~334 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=13b63911a4f6be554296b12ab34d4164d08d465e;p=openldap ITS#2318: unlink pid file (and args file) --- diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 10ab52ae2c..d9e19b4f97 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -524,31 +524,38 @@ int main( int argc, char **argv ) goto shutdown; } - { - FILE *fp; - #ifdef NEW_LOGGING - LDAP_LOG( SLAPD, INFO, "main: slapd starting.\n", 0, 0, 0 ); + LDAP_LOG( SLAPD, INFO, "main: slapd starting.\n", 0, 0, 0 ); #else - Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 ); #endif - if (( slapd_pid_file != NULL ) && - (( fp = fopen( slapd_pid_file, "w" )) != NULL )) - { + if ( slapd_pid_file != NULL ) { + FILE *fp = fopen( slapd_pid_file, "w" ); + + if( fp != NULL ) { fprintf( fp, "%d\n", (int) getpid() ); fclose( fp ); + + } else { + free(slapd_pid_file); + slapd_pid_file = NULL; } + } - if (( slapd_args_file != NULL ) && - (( fp = fopen( slapd_args_file, "w" )) != NULL )) - { + if ( slapd_args_file != NULL ) { + FILE *fp = fopen( slapd_args_file, "w" ); + + if( fp != NULL ) { for ( i = 0; i < g_argc; i++ ) { fprintf( fp, "%s ", g_argv[i] ); } fprintf( fp, "\n" ); fclose( fp ); + } else { + free(slapd_args_file); + slapd_args_file = NULL; } } @@ -607,6 +614,13 @@ stop: ldap_pvt_tls_destroy(); #endif + if ( slapd_pid_file != NULL ) { + unlink( slapd_pid_file ); + } + if ( slapd_args_file != NULL ) { + unlink( slapd_args_file ); + } + config_destroy(); #ifdef CSRIMALLOC