From 30f953160ffb0560f30d1f91caa864d26dc10c31 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 29 Mar 1999 01:40:17 +0000 Subject: [PATCH] Add wait4/3 detection. Modify slapd_tester to use pid_t and wait macros. May need to implement additional macros in ac/wait.h (in addition to WEXITSTATUS and WIFEXITED). --- configure | 31 ++++++++++++++++--------------- configure.in | 1 + include/portable.h.in | 3 +++ tests/progs/slapd-tester.c | 38 ++++++++++++++++++++++++-------------- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/configure b/configure index 8400c6d845..dac0c73eeb 100755 --- a/configure +++ b/configure @@ -10103,15 +10103,16 @@ for ac_func in \ strspn \ sysconf \ waitpid \ + wait4 \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:10110: checking for $ac_func" >&5 +echo "configure:10111: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10139: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -10162,12 +10163,12 @@ done for ac_func in getopt tempnam do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:10166: checking for $ac_func" >&5 +echo "configure:10167: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -10220,13 +10221,13 @@ done # Check Configuration echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:10224: checking declaration of sys_errlist" >&5 +echo "configure:10225: checking declaration of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -10236,7 +10237,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:10240: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:10241: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_sys_errlist=yes else @@ -10256,20 +10257,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then EOF echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6 -echo "configure:10260: checking existence of sys_errlist" >&5 +echo "configure:10261: checking existence of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:10273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:10274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ol_cv_have_sys_errlist=yes else @@ -10293,13 +10294,13 @@ fi echo $ac_n "checking strdup declaration""... $ac_c" 1>&6 -echo "configure:10297: checking strdup declaration" >&5 +echo "configure:10298: checking strdup declaration" >&5 if eval "test \"`echo '$''{'ol_cv_dcl_strdup'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -10307,7 +10308,7 @@ int main() { extern char *strdup(); ; return 0; } EOF -if { (eval echo configure:10311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:10312: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_strdup=yes else diff --git a/configure.in b/configure.in index 60e04f4125..b398d4656b 100644 --- a/configure.in +++ b/configure.in @@ -1701,6 +1701,7 @@ AC_CHECK_FUNCS( \ strspn \ sysconf \ waitpid \ + wait4 \ ) dnl We actually may need to replace more than this. diff --git a/include/portable.h.in b/include/portable.h.in index 830038f9d3..8ea0c646e1 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -339,6 +339,9 @@ /* Define if you have the vsprintf function. */ #undef HAVE_VSPRINTF +/* Define if you have the wait4 function. */ +#undef HAVE_WAIT4 + /* Define if you have the waitpid function. */ #undef HAVE_WAITPID diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c index 51f8bee170..322ff16068 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -3,14 +3,16 @@ #include #include -#include #include +#include #include +#include #include #include -#include +#ifdef HAVE_SYS_PARAM_H #include +#endif #include "ldapconfig.h" @@ -305,7 +307,7 @@ get_read_entries( char *filename, char *entries[] ) static void fork_child( char *prog, char *args[] ) { - int pid; + pid_t pid; wait4kids( maxkids ); @@ -332,25 +334,33 @@ static void wait4kids( int nkidval ) { int status; - unsigned char *p; while ( nkids >= nkidval ) { wait( &status ); - p = (unsigned char *) &status; - if ( p[sizeof(int) - 1] == 0177 ) { + + if ( WIFSTOPPED(status) ) { fprintf( stderr, "stopping: child stopped with signal %d\n", - p[sizeof(int) - 2] ); - } else if ( p[sizeof(int) - 1] != 0 ) { + (int) WSTOPSIG(status) ); + + } else if ( WIFSIGNALED(status) ) { fprintf( stderr, - "stopping: child terminated with signal %d\n", - p[sizeof(int) - 1] ); - exit( p[sizeof(int) - 1] ); - } else if ( p[sizeof(int) - 2] != 0 ) { + "stopping: child terminated with signal %d%s\n", + (int) WTERMSIG(status), +#ifdef WCOREDUMP + WCOREDUMP(status) ? ", core dumped" : "" +#else + "" +#endif + ); + exit( WEXITSTATUS(status) ); + + } else if ( WEXITSTATUS(status) != 0 ) { fprintf( stderr, "stopping: child exited with status %d\n", - p[sizeof(int) - 2] ); - exit( p[sizeof(int) - 2] ); + (int) WEXITSTATUS(status) ); + exit( WEXITSTATUS(status) ); + } else { nkids--; } -- 2.39.5