add wait macros. add LDAP_SIGCHLD. and other misc NT cleanups.

This commit is contained in:
Kurt Zeilenga 1999-03-29 09:04:35 +00:00
parent db721ca821
commit b9109a9f20
7 changed files with 86 additions and 33 deletions

View File

@ -52,4 +52,12 @@
# endif
#endif
#ifndef LDAP_SIGCHLD
#ifdef SIGCHLD
#define LDAP_SIGCHLD SIGCHLD
#elif SIGCLD
#define LDAP_SIGCHLD SIGCLD
#endif
#endif
#endif /* _AC_SIGNAL_H */

View File

@ -18,11 +18,28 @@
# include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#define LDAP_HI(s) (((s) >> 8) & 0x377)
#define LDAP_LO(s) ((s) & 0377)
/* These should work on non-POSIX UNIX platforms,
all bets on off on non-POSIX non-UNIX platforms... */
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
# define WIFEXITED(s) (LDAP_LO(s) == 0)
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(s) LDAP_HI(s)
#endif
#ifndef WIFSIGNALED
# define WIFSIGNALED(s) (LDAP_LO(s) > 0 && LDAP_HI(s) == 0)
#endif
#ifndef WTERMSIG
# define WTERMSIG(s) (LDAP_LO(s) & 0177)
#endif
#ifndef WIFSTOPPED
# define WIFSTOPPED(s) (LDAP_LO(s) == 0177 && LDAP_HI(s) != 0)
#endif
#ifndef WSTOPSIG
# define WSTOPSIG(s) LDAP_HI(s)
#endif
#ifdef WCONTINUED

View File

@ -577,15 +577,18 @@ int lber_pvt_sb_set_nonblock( Sockbuf *sb, int nb )
sb->sb_read_ahead = 0;
#endif
}
#ifdef FIONBIO
if (lber_pvt_sb_in_use(sb)) {
#if HAVE_FCNTL
int flags = fcntl(lber_pvt_sb_get_desc(sb), F_GETFL);
flags |= O_NONBLOCK;
return fcntl(lber_pvt_sb_get_desc(sb), F_SETFL, flags);
#elif defined( FIONBIO )
/* WINSOCK requires the status to be a long */
ioctl_t status = (nb!=0);
if (ioctl( lber_pvt_sb_get_desc(sb), FIONBIO, &status ) == -1 ) {
return -1;
}
}
return ioctl( lber_pvt_sb_get_desc(sb), FIONBIO, &status );
#endif /* FIONBIO */
}
return 0;
}
#endif
@ -750,8 +753,9 @@ stream_read( Sockbuf *sb, void *buf, long len )
*/
return tcpread( lber_pvt_sb_get_desc(sb), 0, (unsigned char *)buf,
len, NULL );
#elif (defined(DOS) && (defined(PCNFS) || defined( WINSOCK))) \
|| defined( _WIN32) || defined ( __BEOS__ )
#elif defined( HAVE_PCNFS ) || \
defined( HAVE_WINSOCK ) || defined ( __BEOS__ )
/*
* PCNFS (under DOS)
*/
@ -762,11 +766,13 @@ stream_read( Sockbuf *sb, void *buf, long len )
* 32-bit Windows Socket API (under Windows NT or Windows 95)
*/
return recv( lber_pvt_sb_get_desc(sb), buf, len, 0 );
#elif (defined(DOS) && defined( NCSA ))
#elif defined( HAVE_NCSA )
/*
* NCSA Telnet TCP/IP stack (under DOS)
*/
return nread( lber_pvt_sb_get_desc(sb), buf, len );
#else
return read( lber_pvt_sb_get_desc(sb), buf, len );
#endif
@ -783,8 +789,9 @@ stream_write( Sockbuf *sb, void *buf, long len )
return tcpwrite( lber_pvt_sb_get_desc(sb),
(unsigned char *)(buf),
(len<MAX_WRITE)? len : MAX_WRITE );
#elif (defined(DOS) && (defined(PCNFS) || defined( WINSOCK))) \
|| defined( _WIN32 ) || defined ( __BEOS__ )
#elif defined( HAVE_PCNFS) \
|| defined( HAVE_WINSOCK) || defined ( __BEOS__ )
/*
* PCNFS (under DOS)
*/
@ -795,8 +802,10 @@ stream_write( Sockbuf *sb, void *buf, long len )
* 32-bit Windows Socket API (under Windows NT or Windows 95)
*/
return send( lber_pvt_sb_get_desc(sb), buf, len, 0 );
#elif defined(NCSA)
#elif defined(HAVE_NCSA)
return netwrite( lber_pvt_sb_get_desc(sb), buf, len );
#elif defined(VMS)
/*
* VMS -- each write must be 64K or smaller
@ -862,12 +871,8 @@ dgram_read( Sockbuf *sb, void *buf, long len )
dd = (struct dgram_data *)(sb->sb_iodata);
# if !defined( MACOS) && !defined(DOS) && !defined( _WIN32)
addrlen = sizeof( struct sockaddr );
rc=recvfrom( lber_pvt_sb_get_desc(sb), buf, len, 0, &(dd->src), &addrlen );
# else
UDP not supported
# endif
if ( sb->sb_debug ) {
lber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug,
@ -892,13 +897,10 @@ dgram_write( Sockbuf *sb, void *buf, long len )
dd = (struct dgram_data *)(sb->sb_iodata);
# if !defined( MACOS) && !defined(DOS) && !defined( _WIN32)
rc=sendto( lber_pvt_sb_get_desc(sb), buf, len, 0, &(dd->dst),
sizeof( struct sockaddr ) );
# else
UDP not supported
# endif
if ( rc <= 0 )
if ( rc <= 0 )
return( -1 );
/* fake error if write was not atomic */

View File

@ -15,12 +15,18 @@
#include <stdio.h>
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include "lutil.h"
@ -82,13 +88,15 @@ lutil_detach( int debug, int do_close )
#ifdef HAVE_SETSID
(void) setsid();
#else /* HAVE_SETSID */
#elif TIOCNOTTY
if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
(void) ioctl( sd, TIOCNOTTY, NULL );
(void) close( sd );
}
#endif /* HAVE_SETSID */
#endif
}
#ifdef SIGPIPE
(void) SIGNAL( SIGPIPE, SIG_IGN );
#endif
}

View File

@ -100,6 +100,10 @@ SOURCE=..\..\include\ldap_features.h
# End Source File
# Begin Source File
SOURCE=.\lockf.c
# End Source File
# Begin Source File
SOURCE=..\..\include\lutil.h
# End Source File
# Begin Source File
@ -116,11 +120,27 @@ SOURCE=.\md5.c
# End Source File
# Begin Source File
SOURCE=.\memcmp.c
# End Source File
# Begin Source File
SOURCE=.\passwd.c
# End Source File
# Begin Source File
SOURCE=..\..\include\portable.h
# End Source File
# Begin Source File
SOURCE=.\setproctitle.c
# End Source File
# Begin Source File
SOURCE=.\sha1.c
# End Source File
# Begin Source File
SOURCE=.\tempnam.c
# End Source File
# End Target
# End Project

View File

@ -10,7 +10,7 @@
#include "lutil.h"
char *
tempnam( const char *dir, const char *pfx )
(tempnam)( const char *dir, const char *pfx )
{
char *s;

View File

@ -15,7 +15,7 @@
#include "slap.h"
#include "lutil.h" /* Get lutil_detach() */
#if defined(SIGCHLD) || defined(SIGCLD)
#ifdef LDAP_SIGCHLD
static RETSIGTYPE wait4child( int sig );
#endif
@ -226,10 +226,8 @@ main( int argc, char **argv )
#endif
(void) SIGNAL( SIGINT, slap_set_shutdown );
(void) SIGNAL( SIGTERM, slap_set_shutdown );
#ifdef SIGCHLD
(void) SIGNAL( SIGCHLD, wait4child );
#elif defined(SIGCLD)
(void) SIGNAL( SIGCLD, wait4child );
#ifdef LDAP_SIGCHLD
(void) SIGNAL( LDAP_SIGCHLD, wait4child );
#endif
if(!inetd) {
@ -290,7 +288,7 @@ destroy:
}
#if defined(SIGCHLD) || defined(SIGCLD)
#ifdef LDAP_SIGCHLD
/*
* Catch and discard terminated child processes, to avoid zombies.