mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-17 14:00:30 +08:00
Change -d option to not detach even with -d 0 or compiled with --disable-debug.
This commit is contained in:
parent
2e86c0516b
commit
203f5b058f
@ -38,8 +38,7 @@ file ( see
|
||||
).
|
||||
If the
|
||||
.B \-d
|
||||
flag is given and debugging is set to some non-zero
|
||||
value,
|
||||
flag is given, even with a zero argument,
|
||||
.B slapd
|
||||
will not fork and disassociate from the invoking tty.
|
||||
.LP
|
||||
@ -59,7 +58,7 @@ See "The SLAPD and SLURPD Administrator's Guide" for more details on
|
||||
.BI \-d " debug\-level"
|
||||
Turn on debugging as defined by
|
||||
.I debug\-level.
|
||||
If this option is specified,
|
||||
If this option is specified, even with a zero argument,
|
||||
.B slapd
|
||||
will not fork or disassociate from the invoking terminal. Some general
|
||||
operation and status messages are printed for any value of \fIdebug\-level\fP.
|
||||
|
@ -62,7 +62,7 @@ for details on the standalone LDAP daemon.
|
||||
.BI \-d " debug\-level"
|
||||
Turn on debugging as defined by
|
||||
.I debug\-level.
|
||||
If this option is specified,
|
||||
If this option is specified, even with a zero argument,
|
||||
.B slurpd
|
||||
will not fork or disassociate from the invoking terminal. Some general
|
||||
operation and status messages are printed for any value of \fIdebug\-level\fP.
|
||||
|
@ -106,6 +106,7 @@ main( int argc, char **argv )
|
||||
int udps;
|
||||
#endif
|
||||
int myport = LDAP_PORT;
|
||||
int no_detach = 0;
|
||||
int i, pid, socktype;
|
||||
char *myname;
|
||||
fd_set readfds;
|
||||
@ -150,13 +151,15 @@ main( int argc, char **argv )
|
||||
dsapargc = 3;
|
||||
break;
|
||||
|
||||
case 'd': /* turn on debugging */
|
||||
case 'd': /* set debug level and 'do not detach' flag */
|
||||
no_detach = 1;
|
||||
#ifdef LDAP_DEBUG
|
||||
ldap_debug = atoi( optarg );
|
||||
if ( ldap_debug & LDAP_DEBUG_PACKETS )
|
||||
ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug );
|
||||
#else
|
||||
fprintf( stderr, "Not compiled with -DLDAP_DEBUG!\n" );
|
||||
if ( atoi( optarg ) != 0 )
|
||||
fputs( "Not compiled with -DLDAP_DEBUG!\n", stderr );
|
||||
#endif
|
||||
break;
|
||||
|
||||
@ -261,11 +264,7 @@ main( int argc, char **argv )
|
||||
setproctitle( "initializing" );
|
||||
#endif
|
||||
#ifndef VMS
|
||||
# ifdef LDAP_DEBUG
|
||||
lutil_detach( ldap_debug, 1 );
|
||||
# else
|
||||
lutil_detach( 0, 1 );
|
||||
# endif
|
||||
lutil_detach( no_detach, 1 );
|
||||
#endif
|
||||
(void) SIGNAL( SIGCHLD, wait4child );
|
||||
(void) SIGNAL( SIGINT, log_and_exit );
|
||||
|
@ -132,7 +132,7 @@ void WINAPI ServiceMain( DWORD argc, LPTSTR *argv )
|
||||
int main( int argc, char **argv )
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
int i, no_detach = 0;
|
||||
int rc;
|
||||
char *urls = NULL;
|
||||
#if defined(HAVE_SETUID) && defined(HAVE_SETGID)
|
||||
@ -233,16 +233,16 @@ int main( int argc, char **argv )
|
||||
urls = ch_strdup( optarg );
|
||||
break;
|
||||
|
||||
case 'd': /* set debug level and 'do not detach' flag */
|
||||
no_detach = 1;
|
||||
#ifdef LDAP_DEBUG
|
||||
case 'd': /* turn on debugging */
|
||||
slap_debug |= atoi( optarg );
|
||||
break;
|
||||
#else
|
||||
case 'd': /* turn on debugging */
|
||||
fprintf( stderr,
|
||||
"must compile with LDAP_DEBUG for debugging\n" );
|
||||
break;
|
||||
if ( atoi( optarg ) != 0 )
|
||||
fputs( "must compile with LDAP_DEBUG for debugging\n",
|
||||
stderr );
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'f': /* read config file */
|
||||
configfile = ch_strdup( optarg );
|
||||
@ -389,11 +389,7 @@ int main( int argc, char **argv )
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WINSOCK
|
||||
#ifdef LDAP_DEBUG
|
||||
lutil_detach( ldap_debug, 0 );
|
||||
#else
|
||||
lutil_detach( 0, 0 );
|
||||
#endif
|
||||
lutil_detach( no_detach, 0 );
|
||||
#endif /* HAVE_WINSOCK */
|
||||
|
||||
#ifdef CSRIMALLOC
|
||||
|
@ -65,9 +65,10 @@ doargs(
|
||||
|
||||
while ( (i = getopt( argc, argv, "hd:f:r:t:k:o" )) != EOF ) {
|
||||
switch ( i ) {
|
||||
case 'd': /* turn on debugging */
|
||||
#ifdef LDAP_DEBUG
|
||||
case 'd': /* set debug level and 'do not detach' flag */
|
||||
g->no_detach = 1;
|
||||
if ( optarg[0] == '?' ) {
|
||||
#ifdef LDAP_DEBUG
|
||||
printf( "Debug levels:\n" );
|
||||
printf( "\tLDAP_DEBUG_TRACE\t%d\n",
|
||||
LDAP_DEBUG_TRACE );
|
||||
@ -87,13 +88,18 @@ doargs(
|
||||
LDAP_DEBUG_ACL );
|
||||
printf( "\tLDAP_DEBUG_ANY\t\t%d\n",
|
||||
LDAP_DEBUG_ANY );
|
||||
puts( "\tThe -d flag also prevents slurpd from detaching." );
|
||||
#endif /* LDAP_DEBUG */
|
||||
puts( "\tDebugging is disabled. -d 0 prevents slurpd from detaching." );
|
||||
return( -1 );
|
||||
} else {
|
||||
ldap_debug |= atoi( optarg );
|
||||
}
|
||||
#else /* LDAP_DEBUG */
|
||||
#ifdef LDAP_DEBUG
|
||||
ldap_debug |= atoi( optarg );
|
||||
#else /* !LDAP_DEBUG */
|
||||
if ( atoi( optarg ) != 0 )
|
||||
/* can't enable debugging - not built with debug code */
|
||||
fprintf( stderr, "must compile with LDAP_DEBUG for debugging\n" );
|
||||
fputs( "must compile with LDAP_DEBUG for debugging\n",
|
||||
stderr );
|
||||
#endif /* LDAP_DEBUG */
|
||||
break;
|
||||
case 'f': /* slapd config file */
|
||||
|
@ -55,6 +55,7 @@ init_globals( void )
|
||||
g->slurpd_replogfile[ 0 ] = '\0';
|
||||
g->slurpd_status_file[ 0 ] = '\0';
|
||||
g->one_shot_mode = 0;
|
||||
g->no_detach = 0;
|
||||
g->myname = NULL;
|
||||
g->srpos = 0L;
|
||||
if ( St_init( &(g->st)) < 0 ) {
|
||||
|
@ -44,6 +44,8 @@ typedef struct globals {
|
||||
char slurpd_replogfile[ MAXPATHLEN ];
|
||||
/* Non-zero if we were given a replog file to process on command-line */
|
||||
int one_shot_mode;
|
||||
/* Non-zero if we should not detach the process */
|
||||
int no_detach;
|
||||
/* Name of program */
|
||||
char *myname;
|
||||
/* Current offset into slurpd replica logfile */
|
||||
|
@ -87,14 +87,10 @@ main(
|
||||
}
|
||||
|
||||
/*
|
||||
* Detach from the controlling terminal, if debug level = 0,
|
||||
* and if not in one-shot mode.
|
||||
* Detach from the controlling terminal
|
||||
* unless the -d flag is given or in one-shot mode.
|
||||
*/
|
||||
#ifdef LDAP_DEBUG
|
||||
if (( ldap_debug == 0 ) && !sglob->one_shot_mode )
|
||||
#else /* LDAP_DEBUG */
|
||||
if ( !sglob->one_shot_mode )
|
||||
#endif /* LDAP_DEBUG */
|
||||
if ( ! (sglob->no_detach || sglob->one_shot_mode) )
|
||||
lutil_detach( 0, 0 );
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user