From 66c6ad4d4e3efbd4ba6bf1eaf288226f3e05b09c Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Wed, 23 Nov 2016 10:38:21 -0700 Subject: [PATCH] microcode (OS_test_select_registry): Check for subprocess status changes when !blockp and the registry is empty. This is most easily done in OS_pause, where OS_process_any_status_change (if any) is available. Thus OS_pause gets a new param BLOCKP. --- src/microcode/ntio.c | 6 +++--- src/microcode/osio.h | 2 +- src/microcode/prosio.c | 2 +- src/microcode/uxio.c | 42 ++++++++++++++++++++++++++---------------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/microcode/ntio.c b/src/microcode/ntio.c index 0d9acf5b6..3ff42eec8 100644 --- a/src/microcode/ntio.c +++ b/src/microcode/ntio.c @@ -848,12 +848,12 @@ OS_test_select_registry (select_registry_t registry, int blockp) } int -OS_pause (bool ignore_status_change) +OS_pause (bool blockp, bool ignore_status_change) { - /* Wait-for-io must spin. */ return - ((OS_process_any_status_change ()) + ((!ignore_status_change && (OS_process_any_status_change ())) ? SELECT_PROCESS_STATUS_CHANGE + /* Wait-for-io must spin. */ : SELECT_INTERRUPT); } diff --git a/src/microcode/osio.h b/src/microcode/osio.h index f03977bb2..0600a8b6e 100644 --- a/src/microcode/osio.h +++ b/src/microcode/osio.h @@ -110,6 +110,6 @@ extern int OS_test_select_registry (select_registry_t registry, int blockp); extern int OS_test_select_descriptor (int fd, int blockp, unsigned int mode); -extern int OS_pause (bool ignore_status_change); +extern int OS_pause (bool blockp, bool ignore_status_change); #endif /* SCM_OSIO_H */ diff --git a/src/microcode/prosio.c b/src/microcode/prosio.c index 85153f2d6..6ffd2e0e8 100644 --- a/src/microcode/prosio.c +++ b/src/microcode/prosio.c @@ -332,7 +332,7 @@ DEFINE_PRIMITIVE ("TEST-SELECT-REGISTRY", Prim_test_selreg, 4, 4, 0) if ((VECTOR_LENGTH (vmode)) < rl) error_bad_range_arg (4); result = ((rl == 0) - ? (blockp ? (OS_pause (0)) : SELECT_INTERRUPT) + ? (OS_pause (blockp, 0)) : (OS_test_select_registry (r, blockp))); if (result > 0) { diff --git a/src/microcode/uxio.c b/src/microcode/uxio.c index 776523ca9..e811f00d9 100644 --- a/src/microcode/uxio.c +++ b/src/microcode/uxio.c @@ -868,27 +868,37 @@ OS_test_select_descriptor (int fd, int blockp, unsigned int mode) #endif /* not HAVE_POLL */ int -OS_pause (bool ignore_status_change) +OS_pause (bool blockp, bool ignore_status_change) { -#ifdef HAVE_SIGSUSPEND - sigset_t old, new; int n; - UX_sigfillset (&new); - UX_sigprocmask (SIG_SETMASK, &new, &old); - if (!ignore_status_change && OS_process_any_status_change ()) - n = SELECT_PROCESS_STATUS_CHANGE; - else if ((GET_INT_CODE) != 0) - n = SELECT_INTERRUPT; - else + if (!blockp) { - UX_sigsuspend (&old); - if (OS_process_any_status_change ()) - n = SELECT_PROCESS_STATUS_CHANGE; - else - n = SELECT_INTERRUPT; + if (!ignore_status_change && OS_process_any_status_change ()) + return (SELECT_PROCESS_STATUS_CHANGE); + return (SELECT_INTERRUPT); } - UX_sigprocmask (SIG_SETMASK, &old, NULL); + +#ifdef HAVE_SIGSUSPEND + { + sigset_t old, new; + + UX_sigfillset (&new); + UX_sigprocmask (SIG_SETMASK, &new, &old); + if (!ignore_status_change && OS_process_any_status_change ()) + n = SELECT_PROCESS_STATUS_CHANGE; + else if ((GET_INT_CODE) != 0) + n = SELECT_INTERRUPT; + else + { + UX_sigsuspend (&old); + if (OS_process_any_status_change ()) + n = SELECT_PROCESS_STATUS_CHANGE; + else + n = SELECT_INTERRUPT; + } + UX_sigprocmask (SIG_SETMASK, &old, NULL); + } #else /* not HAVE_SIGSUSPEND */ INTERRUPTABLE_EXTENT (n, (((!ignore_status_change && (OS_process_any_status_change ())) -- 2.25.1