]> git.sur5r.net Git - openldap/commitdiff
replace detach.c with lutil_detach()
authorHallvard Furuseth <hallvard@openldap.org>
Thu, 5 Nov 1998 01:56:41 +0000 (01:56 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Thu, 5 Nov 1998 01:56:41 +0000 (01:56 +0000)
clients/gopher/Makefile.in
clients/gopher/detach.c [deleted file]
clients/gopher/go500.c
clients/gopher/go500gw.c
servers/ldapd/Makefile.in
servers/ldapd/detach.c [deleted file]
servers/ldapd/main.c
servers/slurpd/Makefile.in
servers/slurpd/detach.c [deleted file]
servers/slurpd/main.c

index baa5437cb0b2055898a087405ce00826e8dc8920..6ce58c5014b5b9a68d11e36f8d132601a9efb79d 100644 (file)
@@ -3,10 +3,10 @@
 ##
 PROGRAMS= go500gw go500
 
-SRCS=  detach.c go500.c go500gw.c 
+SRCS=  go500.c go500gw.c 
 XSRCS= gwversion.o goversion.o
-GOOBJS =  go500.o detach.o
-GWOBJS =  go500gw.o detach.o
+GOOBJS =  go500.o
+GWOBJS =  go500gw.o
 
 LDAP_INCDIR= ../../include
 LDAP_LIBDIR= ../../libraries
diff --git a/clients/gopher/detach.c b/clients/gopher/detach.c
deleted file mode 100644 (file)
index 8a8baa6..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-#include <signal.h>
-
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include <ac/unistd.h>
-
-detach( debug )
-int    debug;
-{
-       int     i, sd, nbits;
-
-#if defined( HAVE_SYSCONF )
-       nbits = sysconf( _SC_OPEN_MAX );
-#elif defined( HAVE_GETDTABLESIZE )
-       nbits = getdtablesize();
-#else
-       nbits = FD_SETSIZE;
-#endif
-
-#ifdef FD_SETSIZE
-       if (nbits > FD_SETSIZE) {
-               nbits = FD_SETSIZE;
-       }
-#endif /* FD_SETSIZE*/
-
-       if ( debug == 0 || !(isatty( 1 )) ) {
-               for ( i = 0; i < 5; i++ ) {
-                       switch ( fork() ) {
-                       case -1:
-                               sleep( 5 );
-                               continue;
-
-                       case 0:
-                               break;
-
-                       default:
-                               _exit( 0 );
-                       }
-                       break;
-               }
-
-               for ( i = 3; i < nbits; i++ )
-                       close( i );
-
-               (void) chdir( "/" );
-
-               if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
-                       if ( debug ) perror( "/dev/null" );
-                       exit( 1 );
-               }
-               if ( isatty( 0 ) )
-                       (void) dup2( sd, 0 );
-               if ( isatty( 1 ) )
-                       (void) dup2( sd, 1 );
-               if ( isatty(2) )
-                       (void) dup2( sd, 2 );
-               close( sd );
-
-#ifdef HAVE_SETSID
-               (void) setsid();
-#else /* HAVE_SETSID */
-               if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
-                       (void) ioctl( sd, TIOCNOTTY, NULL );
-                       (void) close( sd );
-               }
-#endif /* HAVE_SETSID */
-       } 
-
-       (void) signal( SIGPIPE, SIG_IGN );
-}
index 3a951d9a6f06b944ba03d1db48e1bc027c4431b4..e9cb600ef8c9399a6f9a50ee5bd704b831da35e6 100644 (file)
@@ -35,6 +35,7 @@
 #include "lber.h"
 #include "ldap.h"
 #include "ldap_log.h"
+#include "lutil.h"
 
 #include "disptmpl.h"
 
@@ -158,7 +159,7 @@ char        **argv;
 
        /* detach if stderr is redirected or no debugging */
        if ( inetd == 0 )
-               (void) detach( debug );
+               lutil_detach( debug && !isatty( 1 ), 1 );
 
        if ( (myname = strrchr( argv[0], '/' )) == NULL )
                myname = strdup( argv[0] );
index 3a0dab6775a71e63296c19c61607a0577d42dda4..bf25933d3fda1d61f6a4e5a060a593510e240411 100644 (file)
@@ -34,6 +34,7 @@
 #include "lber.h"
 #include "ldap.h"
 #include "ldap_log.h"
+#include "lutil.h"
 
 #include "disptmpl.h"
 
@@ -180,7 +181,7 @@ char        **argv;
 
        /* detach if stderr is redirected or no debugging */
        if ( inetd == 0 )
-               (void) detach( debug );
+               lutil_detach( debug && !isatty( 1 ), 1 );
 
        if ( (myname = strrchr( argv[0], '/' )) == NULL )
                myname = strdup( argv[0] );
index d45e02e38c2c9808c20dfe96e804bdb19d917086..190e570f60c0cbc4a8d71c0e526b1f8619b9c4c4 100644 (file)
@@ -3,10 +3,10 @@
 ##
 PROGRAMS=ldapd
 XPROGRAMS=sldapd
-SRCS   = main.c detach.c request.c bind.c result.c error.c \
+SRCS   = main.c request.c bind.c result.c error.c \
        search.c util.c compare.c message.c add.c delete.c modrdn.c modify.c \
        abandon.c syntax.c association.c kerberos.c certificate.c
-OBJS   = main.o detach.o request.o bind.o result.o error.o \
+OBJS   = main.o request.o bind.o result.o error.o \
        search.o util.o compare.o message.o add.o delete.o modrdn.o modify.o \
        abandon.o syntax.o association.o kerberos.o LDAP_tables.o \
        certificate.o
diff --git a/servers/ldapd/detach.c b/servers/ldapd/detach.c
deleted file mode 100644 (file)
index 672ccfd..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/signal.h>
-#include <ac/unistd.h>
-
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-
-
-detach()
-{
-       int             i, sd, nbits;
-#ifdef LDAP_DEBUG
-       extern int      ldap_debug;
-#endif
-
-#ifdef HAVE_SYSCONF
-       nbits = sysconf( _SC_OPEN_MAX );
-#elif HAVE_GETDTABLESIZE
-       nbits = getdtablesize();
-#else
-       nbits = FD_SETSIZE
-#endif
-
-#ifdef FD_SETSIZE
-       if( nbits > FD_SETSIZE ) {
-               nbits = FD_SETSIZE;
-       }
-#endif /* FD_SETSIZE */
-
-#ifdef LDAP_DEBUG
-       if ( ldap_debug == 0 ) {
-#endif
-               for ( i = 0; i < 5; i++ ) {
-                       switch ( fork() ) {
-                       case -1:
-                               sleep( 5 );
-                               continue;
-
-                       case 0:
-                               break;
-
-                       default:
-                               _exit( 0 );
-                       }
-                       break;
-               }
-
-               for ( i = 3; i < nbits; i++ )
-                       close( i );
-
-               (void) chdir( "/" );
-
-               if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
-                       perror( "/dev/null" );
-                       exit( 1 );
-               }
-               if ( isatty( 0 ) )
-                       (void) dup2( sd, 0 );
-               if ( isatty( 1 ) )
-                       (void) dup2( sd, 1 );
-               if ( isatty(2) )
-                       (void) dup2( sd, 2 );
-               close( sd );
-
-#ifdef HAVE_SETSID
-               setsid();
-#else /* HAVE_SETSID */
-               if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
-                       (void) ioctl( sd, TIOCNOTTY, NULL );
-                       (void) close( sd );
-               }
-#endif /* HAVE_SETSID */
-#ifdef LDAP_DEBUG
-       } 
-#endif
-
-       (void) signal( SIGPIPE, SIG_IGN );
-}
index 51d5791b465c31684d5cbcb74fb343f7c5cd7988..0d7933d202bf53fc1600d0a0ec5bd49c8f2ee0f7 100644 (file)
@@ -263,11 +263,15 @@ char      **argv;
         * that have exited
         */
        if (!RunFromInetd) {
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                setproctitle( "initializing" );
 #endif
 #ifndef VMS
-               (void) detach();
+#  ifdef LDAP_DEBUG
+               lutil_detach( ldap_debug, 1 );
+#  else
+               lutil_detach( 0, 1 );
+#  endif
 #endif
                (void) SIGNAL( SIGCHLD, (void *) wait4child );
                (void) SIGNAL( SIGINT, (void *) log_and_exit );
@@ -333,7 +337,7 @@ char        **argv;
                                    inet_ntoa( from.sin_addr ) );
                        }
 
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                        sprintf( title, "%s %d\n", hp == NULL ?
                            inet_ntoa( from.sin_addr ) : hp->h_name, myport );
                        setproctitle( title );
@@ -358,7 +362,7 @@ char        **argv;
         * if we are doing CLDAP as well, handle those requests on the fly
         */
 
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
 #ifdef LDAP_CONNECTIONLESS
         sprintf( title, "listening %s/%s %d", do_tcp ? "tcp" : "",
             do_udp ? "udp" : "", myport );
@@ -439,7 +443,7 @@ char        **argv;
 #ifdef VMS
                /* This is for debug on terminal on VMS */
                close( tcps );
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
                    hp->h_name );
 #endif
@@ -453,7 +457,7 @@ char        **argv;
                switch( pid = fork() ) {
                case 0:         /* child */
                        close( tcps );
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                         sprintf( title, "%s (%d)\n", hp == NULL ?
                                inet_ntoa( from.sin_addr ) : hp->h_name,
                                myport );
index 38d674afc079c7174487d15fc0b5911b4920d809..cabff13e50ea065de668aa634f2d3fc95fce2e84 100644 (file)
@@ -3,11 +3,11 @@
 ##
 
 PROGRAMS = slurpd
-SRCS   =       admin.c args.c ch_malloc.c config.c detach.c \
+SRCS   =       admin.c args.c ch_malloc.c config.c \
                fm.c globals.c ldap_op.c lock.c main.c re.c \
                reject.c replica.c replog.c ri.c rq.c sanity.c st.c \
                tsleep.c
-OBJS   =       admin.o args.o ch_malloc.o config.o detach.o \
+OBJS   =       admin.o args.o ch_malloc.o config.o \
                fm.o globals.o ldap_op.o lock.o main.o re.o \
                reject.o replica.o replog.o ri.o rq.o sanity.o st.o \
                tsleep.o
diff --git a/servers/slurpd/detach.c b/servers/slurpd/detach.c
deleted file mode 100644 (file)
index 0f0d36f..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/unistd.h>
-#include <ac/signal.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-
-#include "portable.h"
-
-detach()
-{
-       int             i, sd, nbits;
-#ifdef LDAP_DEBUG
-       extern int      ldap_debug;
-#endif
-
-#ifdef HAVE_SYSCONF
-       nbits = sysconf( _SC_OPEN_MAX );
-#elif HAVE_GETDTABLESIZE
-       nbits = getdtablesize();
-#else
-       nbits = FD_SETSIZE;
-#endif
-
-#ifdef FD_SETSIZE
-       if ( nbits > FD_SETSIZE ) {
-               nbits = FD_SETSIZE;
-       }
-#endif /* FD_SETSIZE */
-
-#ifdef LDAP_DEBUG
-       if ( ldap_debug == 0 ) {
-#endif
-               for ( i = 0; i < 5; i++ ) {
-#if HAVE_THR
-                       switch ( fork1() ) {
-#else
-                       switch ( fork() ) {
-#endif
-                       case -1:
-                               sleep( 5 );
-                               continue;
-
-                       case 0:
-                               break;
-
-                       default:
-                               _exit( 0 );
-                       }
-                       break;
-               }
-
-/*
-               for ( i = 3; i < nbits; i++ )
-                       close( i );
-*/
-
-               (void) chdir( "/" );
-
-               if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
-                       perror( "/dev/null" );
-                       exit( 1 );
-               }
-               if ( isatty( 0 ) )
-                       (void) dup2( sd, 0 );
-               if ( isatty( 1 ) )
-                       (void) dup2( sd, 1 );
-               if ( isatty(2) )
-                       (void) dup2( sd, 2 );
-               close( sd );
-
-#ifdef HAVE_SETSID
-               setsid();
-#else /* HAVE_SETSID */
-               if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
-                       (void) ioctl( sd, TIOCNOTTY, NULL );
-                       (void) close( sd );
-               }
-#endif /* HAVE_SETSID */
-#ifdef LDAP_DEBUG
-       } 
-#endif
-
-       (void) SIGNAL( SIGPIPE, SIG_IGN );
-}
index d780ed30384bcae27182f50233b579f8933417d5..061aefa080fbd7b048c43b35996f515bd57da076 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "slurp.h"
 #include "globals.h"
+#include "lutil.h"
 
 
 extern int             doargs( int, char **, Globals * );
@@ -100,9 +101,7 @@ main(
 #else /* LDAP_DEBUG */
     if ( !sglob->one_shot_mode )
 #endif /* LDAP_DEBUG */
-       {
-               detach();
-    }
+       lutil_detach( 0, 0 );
 
 #if defined( HAVE_LWP )
     /*