mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-22 23:59:34 -05:00
Generate pid/arg files after detaching
This commit is contained in:
parent
a53514078c
commit
81f1a24e1b
1 changed files with 31 additions and 30 deletions
|
|
@ -178,43 +178,44 @@ int main( int argc, char **argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( slurpd_pid_file != NULL ) {
|
|
||||||
FILE *fp = fopen( slurpd_pid_file, "w" );
|
|
||||||
|
|
||||||
if( fp != NULL ) {
|
|
||||||
fprintf( fp, "%d\n", (int) getpid() );
|
|
||||||
fclose( fp );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
free(slurpd_pid_file);
|
|
||||||
slurpd_pid_file = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( slurpd_args_file != NULL ) {
|
|
||||||
FILE *fp = fopen( slurpd_args_file, "w" );
|
|
||||||
|
|
||||||
if( fp != NULL ) {
|
|
||||||
for ( i = 0; i < argc; i++ ) {
|
|
||||||
fprintf( fp, "%s ", argv[i] );
|
|
||||||
}
|
|
||||||
fprintf( fp, "\n" );
|
|
||||||
fclose( fp );
|
|
||||||
} else {
|
|
||||||
free(slurpd_args_file);
|
|
||||||
slurpd_args_file = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detach from the controlling terminal
|
* Detach from the controlling terminal
|
||||||
* unless the -d flag is given or in one-shot mode.
|
* unless the -d flag is given or in one-shot mode.
|
||||||
*/
|
*/
|
||||||
#ifndef HAVE_WINSOCK
|
#ifndef HAVE_WINSOCK
|
||||||
if ( ! (sglob->no_detach || sglob->one_shot_mode) )
|
if ( ! (sglob->no_detach || sglob->one_shot_mode) ) {
|
||||||
lutil_detach( 0, 0 );
|
lutil_detach( 0, 0 );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ( slurpd_pid_file != NULL ) {
|
||||||
|
FILE *fp = fopen( slurpd_pid_file, "w" );
|
||||||
|
|
||||||
|
if( fp != NULL ) {
|
||||||
|
fprintf( fp, "%d\n", (int) getpid() );
|
||||||
|
fclose( fp );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
free(slurpd_pid_file);
|
||||||
|
slurpd_pid_file = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( slurpd_args_file != NULL ) {
|
||||||
|
FILE *fp = fopen( slurpd_args_file, "w" );
|
||||||
|
|
||||||
|
if( fp != NULL ) {
|
||||||
|
for ( i = 0; i < argc; i++ ) {
|
||||||
|
fprintf( fp, "%s ", argv[i] );
|
||||||
|
}
|
||||||
|
fprintf( fp, "\n" );
|
||||||
|
fclose( fp );
|
||||||
|
} else {
|
||||||
|
free(slurpd_args_file);
|
||||||
|
slurpd_args_file = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( (rc = lutil_pair( sglob->wake_sds )) < 0 ) {
|
if ( (rc = lutil_pair( sglob->wake_sds )) < 0 ) {
|
||||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
|
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
|
||||||
rc = 1;
|
rc = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue