).
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
.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.
.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.
int udps;
#endif
int myport = LDAP_PORT;
+ int no_detach = 0;
int i, pid, socktype;
char *myname;
fd_set readfds;
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;
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 );
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)
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 );
#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
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 );
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 */
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 ) {
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 */
}
/*
- * 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 );
/*