mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-04-06 15:00:40 +08:00
replace detach.c with lutil_detach()
This commit is contained in:
parent
bc6658be46
commit
f3db3e0a8f
@ -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
|
||||
|
@ -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 );
|
||||
}
|
@ -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] );
|
||||
|
@ -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] );
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
}
|
@ -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 );
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
}
|
@ -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 )
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user