From: markus schnalke Date: Mon, 26 Mar 2012 20:57:27 +0000 (+0200) Subject: Clean up process wait to use POSIX waitpid() interface. X-Git-Tag: mmh-thesis-end~182 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=0c648c7c1509760370d4c4267a45a5a305885e7f;p=mmh Clean up process wait to use POSIX waitpid() interface. Merged from nmh. Thanks to Lyndon Nerenberg. --- diff --git a/configure.ac b/configure.ac index 8c9262b..9fd84c8 100644 --- a/configure.ac +++ b/configure.ac @@ -337,7 +337,6 @@ AC_SUBST(OURDEFS) AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_TIME -AC_HEADER_SYS_WAIT AC_HEADER_STAT AC_HEADER_TIOCGWINSZ AC_CHECK_HEADERS(fcntl.h crypt.h termcap.h \ @@ -363,7 +362,7 @@ AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM,1, dnl --------------- dnl CHECK FUNCTIONS dnl --------------- -AC_CHECK_FUNCS(waitpid sigaction sigprocmask sigblock sigsetmask \ +AC_CHECK_FUNCS(sigaction sigprocmask sigblock sigsetmask \ sighold sigrelse lstat tzset \ getutent nl_langinfo mbtowc wcwidth) @@ -574,34 +573,6 @@ AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, AC_CHECK_MEMBERS(struct utmp.ut_type,,,[#include ]) -AC_MSG_CHECKING(for union wait) -AC_CACHE_VAL(nmh_cv_union_wait, [dnl - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include -#include ]], - [[union wait status; int pid; pid = wait (&status); -#ifdef WEXITSTATUS -/* Some POSIXoid systems have both the new-style macros and the old - union wait type, and they do not work together. If union wait - conflicts with WEXITSTATUS et al, we don't want to use it at all. */ - if (WEXITSTATUS (status) != 0) pid = -1; -#ifdef WTERMSIG - /* If we have WEXITSTATUS and WTERMSIG, just use them on ints. */ - -- blow chunks here -- -#endif -#endif -#ifdef HAVE_WAITPID - /* Make sure union wait works with waitpid. */ - pid = waitpid (-1, &status, 0); -#endif - ]])], - [nmh_cv_union_wait=yes], - [nmh_cv_union_wait=no])]) -if test "$nmh_cv_union_wait" = yes; then - AC_DEFINE(HAVE_UNION_WAIT, 1, - [Define to 1 if you have the \`union wait' type in .]) -fi -AC_MSG_RESULT($nmh_cv_union_wait) - CHECK_TYPE_STRUCT_DIRENT_D_TYPE() dnl ------------- diff --git a/sbr/pidstatus.c b/sbr/pidstatus.c index f845058..a9befee 100644 --- a/sbr/pidstatus.c +++ b/sbr/pidstatus.c @@ -12,10 +12,7 @@ ** auto-generated header */ #include - -#ifdef HAVE_SYS_WAIT_H -# include -#endif +#include #ifndef WTERMSIG # define WTERMSIG(s) ((int)((s) & 0x7F)) diff --git a/sbr/pidwait.c b/sbr/pidwait.c index ebee02e..ba9bae2 100644 --- a/sbr/pidwait.c +++ b/sbr/pidwait.c @@ -10,22 +10,14 @@ #include #include #include - -#ifdef HAVE_SYS_WAIT_H -# include -#endif +#include int pidwait(pid_t id, int sigsok) { pid_t pid; SIGNAL_HANDLER istat = NULL, qstat = NULL; - -#ifdef HAVE_UNION_WAIT - union wait status; -#else int status; -#endif if (sigsok == -1) { /* ignore a couple of signals */ @@ -33,13 +25,8 @@ pidwait(pid_t id, int sigsok) qstat = SIGNAL(SIGQUIT, SIG_IGN); } -#ifdef HAVE_WAITPID while ((pid = waitpid(id, &status, 0)) == -1 && errno == EINTR) ; -#else - while ((pid = wait(&status)) != -1 && pid != id) - continue; -#endif if (sigsok == -1) { /* reset the signal handlers */ @@ -47,9 +34,5 @@ pidwait(pid_t id, int sigsok) SIGNAL(SIGQUIT, qstat); } -#ifdef HAVE_UNION_WAIT - return (pid == -1 ? -1 : status.w_status); -#else return (pid == -1 ? -1 : status); -#endif } diff --git a/uip/mhbuild.c b/uip/mhbuild.c index 3ed31f9..06a353a 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -36,10 +36,6 @@ # endif #endif -#ifdef HAVE_SYS_WAIT_H -# include -#endif - static struct swit switches[] = { #define CHECKSW 0 { "check", 0 }, diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 7bd4cfb..975d2e1 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -30,10 +30,6 @@ # endif #endif -#ifdef HAVE_SYS_WAIT_H -# include -#endif - extern int debugsw; extern pid_t xpid; /* mhshowsbr.c or mhbuild.c */ diff --git a/uip/mhlist.c b/uip/mhlist.c index 8902f75..a06a678 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -18,10 +18,6 @@ #include #include -#ifdef HAVE_SYS_WAIT_H -# include -#endif - static struct swit switches[] = { #define CHECKSW 0 { "check", 0 }, diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index 00b538c..f82cc6c 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -17,11 +17,6 @@ #include #include -#ifdef HAVE_SYS_WAIT_H -# include -#endif - - extern int ebcdicsw; static char ebcdicsafe[0x100] = { diff --git a/uip/mhparse.c b/uip/mhparse.c index ece4e8f..d38f251 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -18,11 +18,6 @@ #include #include -#ifdef HAVE_SYS_WAIT_H -# include -#endif - - extern int debugsw; extern int endian; /* mhmisc.c */ diff --git a/uip/mhshow.c b/uip/mhshow.c index bbd99ea..6d91e59 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -18,10 +18,6 @@ #include #include -#ifdef HAVE_SYS_WAIT_H -# include -#endif - static struct swit switches[] = { #define CHECKSW 0 { "check", 0 }, diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 3e730ce..38167c8 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -17,10 +17,7 @@ #include #include #include - -#ifdef HAVE_SYS_WAIT_H -# include -#endif +#include /* ** Just use sigjmp/longjmp on older machines that @@ -116,12 +113,7 @@ static void show_single_message(CT ct, char *form) { sigset_t set, oset; - -#ifdef HAVE_UNION_WAIT - union wait status; -#else int status; -#endif /* ** Allow user executable bit so that temporary directories created by @@ -157,11 +149,7 @@ show_single_message(CT ct, char *form) SIGPROCMASK(SIG_BLOCK, &set, &oset); while (wait(&status) != NOTOK) { -#ifdef HAVE_UNION_WAIT - pidcheck(status.w_status); -#else pidcheck(status); -#endif continue; } @@ -739,11 +727,7 @@ show_multi_internal(CT ct, int serial, int alternate) if (serial && !nowserial) { pid_t pid; int kids; -#ifdef HAVE_UNION_WAIT - union wait status; -#else int status; -#endif kids = 0; for (part = m->mp_parts; part; part = part->mp_next) { @@ -758,11 +742,7 @@ show_multi_internal(CT ct, int serial, int alternate) } while (kids > 0 && (pid = wait(&status)) != NOTOK) { -#ifdef HAVE_UNION_WAIT - pidcheck(status.w_status); -#else pidcheck(status); -#endif for (part = m->mp_parts; part; part = part->mp_next) { p = part->mp_part; diff --git a/uip/mhstore.c b/uip/mhstore.c index 2ed6a42..1c4cee6 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -19,10 +19,6 @@ #include #include -#ifdef HAVE_SYS_WAIT_H -# include -#endif - static struct swit switches[] = { #define AUTOSW 0 { "auto", 0 }, diff --git a/uip/mhtest.c b/uip/mhtest.c index 7dc9c07..f6c14fb 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -18,10 +18,6 @@ #include #include -#ifdef HAVE_SYS_WAIT_H -# include -#endif - static struct swit switches[] = { #define CHECKSW 0 { "check", 0 },