diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | ace/Process.cpp | 44 | ||||
-rw-r--r-- | ace/Process_Manager.cpp | 24 | ||||
-rw-r--r-- | ace/config-openvms.h | 7 |
4 files changed, 82 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog index 6d377b2e250..d3855dc9489 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Thu Sep 2 12:51:00 UTC 2004 Martin Corino <mcorino@remedy.nl> + + * ace/config-openvms.h: + + Added ACE_LACKS_UNIX_SIGNALS since OpenVMS cannot use signals + in combination with PTHREAD. + + * ace/Process.cpp: + * ace/Process_Manager.cpp: + + Implemented alternatives in timed wait() functions for systems + with ACE_LACKS_UNIX_SIGNALS and !WIN32. + Thu Sep 2 07:24:20 2004 Chad Elliott <elliott_c@ociweb.com> * bin/MakeProjectCreator/config/core.mpb: diff --git a/ace/Process.cpp b/ace/Process.cpp index 3ff8c38a1f2..bfecc19732c 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -22,7 +22,7 @@ ACE_RCSID (ace, Process, "$Id$") // This function acts as a signal handler for SIGCHLD. We don't really want // to do anything with the signal - it's just needed to interrupt a sleep. // See wait() for more info. -#if !defined (ACE_WIN32) +#if !defined (ACE_WIN32) && !defined(ACE_LACKS_UNIX_SIGNALS) static void sigchld_nop (int, siginfo_t *, ucontext_t *) { @@ -236,7 +236,7 @@ ACE_Process::spawn (ACE_Process_Options &options) // something went wrong this->child_id_ = ACE_INVALID_PID; } - + // restore STD file descriptors (if necessary) if (options.get_stdin () != ACE_INVALID_HANDLE) { if (saved_stdin == -1) @@ -473,7 +473,45 @@ ACE_Process::wait (const ACE_Time_Value &tv, ACE_OS::set_errno_to_last_error (); return -1; } -#else /* ACE_WIN32 */ +#elif defined(ACE_LACKS_UNIX_SIGNALS) + if (tv == ACE_Time_Value::zero) + { + pid_t retv = + ACE_OS::waitpid (this->child_id_, + &this->exit_code_, + WNOHANG); + if (status != 0) + *status = this->exit_code_; + + return retv; + } + + if (tv == ACE_Time_Value::max_time) + return this->wait (status); + + pid_t pid = 0; + ACE_Time_Value sleeptm (1); // 1 msec + if (sleeptm > tv) // if sleeptime > waittime + sleeptm = tv; + ACE_Time_Value tmo (tv); // Need one we can change + for (ACE_Countdown_Time time_left (&tmo); tmo > ACE_Time_Value::zero ; time_left.update ()) + { + pid = ACE_OS::waitpid (this->getpid (), + &this->exit_code_, + WNOHANG); + if (status != 0) + *status = this->exit_code_; + + if (pid > 0 || pid == ACE_INVALID_PID) + break; // Got a child or an error - all done + + // pid 0, nothing is ready yet, so wait. + // Do a (very) short sleep (only this thread sleeps). + ACE_OS::sleep (sleeptm); + } + + return pid; +#else /* !ACE_WIN32 && !ACE_LACKS_UNIX_SIGNALS */ if (tv == ACE_Time_Value::zero) { pid_t retv = diff --git a/ace/Process_Manager.cpp b/ace/Process_Manager.cpp index c51ec494015..f78334c855e 100644 --- a/ace/Process_Manager.cpp +++ b/ace/Process_Manager.cpp @@ -40,7 +40,7 @@ ACE_Process_Manager::cleanup (void *, void *) // This function acts as a signal handler for SIGCHLD. We don't really want // to do anything with the signal - it's just needed to interrupt a sleep. // See wait() for more info. -#if !defined (ACE_WIN32) +#if !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SIGNALS) static void sigchld_nop (int, siginfo_t *, ucontext_t *) { @@ -221,7 +221,7 @@ ACE_Process_Manager::open (size_t size, if (r) { this->reactor (r); -#if !defined (ACE_WIN32) && !defined (ACE_PSOS) +#if !defined (ACE_WIN32) && !defined (ACE_PSOS) && !defined (ACE_LACKS_UNIX_SIGNALS) // Register signal handler object. if (r->register_handler (SIGCHLD, this) == -1) return -1; @@ -264,7 +264,7 @@ ACE_Process_Manager::close (void) { ACE_TRACE ("ACE_Process_Manager::close"); -#if !defined (ACE_WIN32) +#if !defined (ACE_WIN32) && !defined (ACE_LACKS_UNIX_SIGNALS) if (this->reactor ()) { this->reactor ()->remove_handler (SIGCHLD, (ACE_Sig_Action *) 0); @@ -838,6 +838,23 @@ ACE_Process_Manager::wait (pid_t pid, } else { +# if defined (ACE_LACKS_UNIX_SIGNALS) + pid = 0; + ACE_Time_Value sleeptm (1); // 1 msec + if (sleeptm > timeout) // if sleeptime > waittime + sleeptm = timeout; + ACE_Time_Value tmo (timeout); // Need one we can change + for (ACE_Countdown_Time time_left (&tmo); tmo > ACE_Time_Value::zero ; time_left.update ()) + { + pid = ACE_OS::waitpid (-1, status, WNOHANG); + if (pid > 0 || pid == ACE_INVALID_PID) + break; // Got a child or an error - all done + + // pid 0, nothing is ready yet, so wait. + // Do a (very) short sleep (only this thread sleeps). + ACE_OS::sleep (sleeptm); + } +# else // Force generation of SIGCHLD, even though we don't want to // catch it - just need it to interrupt the sleep below. // If this object has a reactor set, assume it was given at @@ -874,6 +891,7 @@ ACE_Process_Manager::wait (pid_t pid, { old_action.register_action (SIGCHLD); } +# endif /* !ACE_LACKS_UNIX_SIGNALS */ } #endif /* !defined (ACE_WIN32) */ } diff --git a/ace/config-openvms.h b/ace/config-openvms.h index f418483da86..797db7091ca 100644 --- a/ace/config-openvms.h +++ b/ace/config-openvms.h @@ -89,6 +89,8 @@ #define ACE_LACKS_PWD_REENTRANT_FUNCTIONS 1 #define ACE_LACKS_RAND_REENTRANT_FUNCTIONS 1 +#define ACE_LACKS_UNIX_SIGNALS 1 + #define ACE_MT_SAFE 1 /*Compile using multi-thread libraries*/ #define ACE_NEW_THROWS_EXCEPTIONS 1 @@ -209,6 +211,8 @@ #define ACE_HAS_SIGWAIT 1 /*Platform/compiler has the sigwait(2) prototype*/ +#define ACE_HAS_SIGTIMEDWAIT 1 + #define ACE_HAS_SIG_C_FUNC 1 /*Compiler requires extern "C" functions for signals.*/ @@ -240,6 +244,9 @@ #define ACE_HAS_TEMPLATE_SPECIALIZATION 1 /*Compiler implements template specialization*/ + +#define ACE_HAS_STD_TEMPLATE_CLASS_MEMBER_SPECIALIZATION 1 + #define ACE_HAS_TEMPLATE_TYPEDEFS 1 /*Compiler implements templates that support typedefs inside |