[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / OS_NS_sys_wait.inl
blobf24c09267d5b8ef3ade3a21161bb634553a74f45
1 // -*- C++ -*-
2 //
3 // $Id: OS_NS_sys_wait.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/OS_NS_errno.h"
6 #include "ace/Global_Macros.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 ACE_INLINE pid_t
11 ACE_OS::wait (int *status)
13   ACE_OS_TRACE ("ACE_OS::wait");
14 #if defined (ACE_LACKS_WAIT)
15   ACE_UNUSED_ARG (status);
16   ACE_NOTSUP_RETURN (0);
17 #else
18   ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
19 #endif /* ACE_LACKS_WAIT */
22 ACE_INLINE pid_t
23 ACE_OS::waitpid (pid_t pid,
24                  ACE_exitcode *status,
25                  int wait_options,
26                  ACE_HANDLE handle)
28   ACE_OS_TRACE ("ACE_OS::waitpid");
29 #if defined (ACE_LACKS_WAITPID)
30   ACE_UNUSED_ARG (pid);
31   ACE_UNUSED_ARG (status);
32   ACE_UNUSED_ARG (wait_options);
33   ACE_UNUSED_ARG (handle);
35   ACE_NOTSUP_RETURN (0);
36 #elif defined (ACE_WIN32)
37   int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
38     ? 0 /* don't hang */
39     : INFINITE;
41   ACE_HANDLE phandle = handle;
43   if (phandle == 0)
44     {
45       phandle = ::OpenProcess (SYNCHRONIZE,
46                                FALSE,
47                                pid);
49       if (phandle == 0)
50         {
51           ACE_OS::set_errno_to_last_error ();
52           return -1;
53         }
54     }
56   pid_t result = pid;
58   // Don't try to get the process exit status if wait failed so we can
59   // keep the original error code intact.
60   switch (::WaitForSingleObject (phandle,
61                                  blocking_period))
62     {
63     case WAIT_OBJECT_0:
64       if (status != 0)
65         // The error status of <GetExitCodeProcess> is nonetheless
66         // not tested because we don't know how to return the value.
67         ::GetExitCodeProcess (phandle,
68                               status);
69       break;
70     case WAIT_TIMEOUT:
71       errno = ETIME;
72       result = 0;
73       break;
74     default:
75       ACE_OS::set_errno_to_last_error ();
76       result = -1;
77     }
78   if (handle == 0)
79     ::CloseHandle (phandle);
80   return result;
81 #elif defined(ACE_TANDEM_T1248_PTHREADS)
82   ACE_UNUSED_ARG (handle);
83   ACE_OSCALL_RETURN (::spt_waitpid (pid, status, wait_options),
84                      pid_t, -1);
85 #else
86   ACE_UNUSED_ARG (handle);
87   ACE_OSCALL_RETURN (::waitpid (pid, status, wait_options),
88                      pid_t, -1);
89 #endif /* ACE_LACKS_WAITPID */
92 ACE_INLINE pid_t
93 ACE_OS::wait (pid_t pid,
94               ACE_exitcode *status,
95               int wait_options,
96               ACE_HANDLE handle)
98   ACE_OS_TRACE ("ACE_OS::wait");
99   return ACE_OS::waitpid (pid,
100                           status,
101                           wait_options,
102                           handle);
105 ACE_END_VERSIONED_NAMESPACE_DECL