00001
00002
00003
00004
00005 #include "ace/OS_NS_errno.h"
00006 #include "ace/Global_Macros.h"
00007
00008 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00009
00010 ACE_INLINE pid_t
00011 ACE_OS::wait (int *status)
00012 {
00013 ACE_OS_TRACE ("ACE_OS::wait");
00014 #if defined (ACE_LACKS_WAIT)
00015 ACE_UNUSED_ARG (status);
00016 ACE_NOTSUP_RETURN (0);
00017 #else
00018 ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
00019 #endif
00020 }
00021
00022 ACE_INLINE pid_t
00023 ACE_OS::waitpid (pid_t pid,
00024 ACE_exitcode *status,
00025 int wait_options,
00026 ACE_HANDLE handle)
00027 {
00028 ACE_OS_TRACE ("ACE_OS::waitpid");
00029 #if defined (ACE_LACKS_WAITPID)
00030 ACE_UNUSED_ARG (pid);
00031 ACE_UNUSED_ARG (status);
00032 ACE_UNUSED_ARG (wait_options);
00033 ACE_UNUSED_ARG (handle);
00034
00035 ACE_NOTSUP_RETURN (0);
00036 #elif defined (ACE_WIN32)
00037 int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
00038 ? 0
00039 : INFINITE;
00040
00041 ACE_HANDLE phandle = handle;
00042
00043 if (phandle == 0)
00044 {
00045 phandle = ::OpenProcess (SYNCHRONIZE,
00046 FALSE,
00047 pid);
00048
00049 if (phandle == 0)
00050 {
00051 ACE_OS::set_errno_to_last_error ();
00052 return -1;
00053 }
00054 }
00055
00056 pid_t result = pid;
00057
00058
00059
00060 switch (::WaitForSingleObject (phandle,
00061 blocking_period))
00062 {
00063 case WAIT_OBJECT_0:
00064 if (status != 0)
00065
00066
00067 ::GetExitCodeProcess (phandle,
00068 status);
00069 break;
00070 case WAIT_TIMEOUT:
00071 errno = ETIME;
00072 result = 0;
00073 break;
00074 default:
00075 ACE_OS::set_errno_to_last_error ();
00076 result = -1;
00077 }
00078 if (handle == 0)
00079 ::CloseHandle (phandle);
00080 return result;
00081 #elif defined(ACE_TANDEM_T1248_PTHREADS)
00082 ACE_UNUSED_ARG (handle);
00083 ACE_OSCALL_RETURN (::spt_waitpid (pid, status, wait_options),
00084 pid_t, -1);
00085 #else
00086 ACE_UNUSED_ARG (handle);
00087 ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options),
00088 pid_t, -1);
00089 #endif
00090 }
00091
00092 ACE_INLINE pid_t
00093 ACE_OS::wait (pid_t pid,
00094 ACE_exitcode *status,
00095 int wait_options,
00096 ACE_HANDLE handle)
00097 {
00098 ACE_OS_TRACE ("ACE_OS::wait");
00099 return ACE_OS::waitpid (pid,
00100 status,
00101 wait_options,
00102 handle);
00103 }
00104
00105 ACE_END_VERSIONED_NAMESPACE_DECL