# include <sys/wait.h>
#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(s) (LDAP_LO(s) == 0)
+#endif
#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+# define WEXITSTATUS(s) LDAP_HI(s)
#endif
-#ifndef WIFEXITED
-# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#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
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
*/
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)
*/
* 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
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)
*/
* 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
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,
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 */
#include "slap.h"
#include "lutil.h" /* Get lutil_detach() */
-#if defined(SIGCHLD) || defined(SIGCLD)
+#ifdef LDAP_SIGCHLD
static RETSIGTYPE wait4child( int sig );
#endif
#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) {
}
-#if defined(SIGCHLD) || defined(SIGCLD)
+#ifdef LDAP_SIGCHLD
/*
* Catch and discard terminated child processes, to avoid zombies.