2 #include "ace/OS_NS_macros.h"
3 #include "ace/OS_NS_errno.h"
4 #include "ace/os_include/os_pthread.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 kill (pid_t pid, int signum)
14 ACE_OS_TRACE ("ACE_OS::kill");
15 #if defined (ACE_LACKS_KILL)
17 ACE_UNUSED_ARG (signum);
18 ACE_NOTSUP_RETURN (-1);
19 #elif defined (ACE_VXWORKS)
21 * The VxWorks kill interface is not really POSIX
22 * since they use a task id in place of a pid type.
23 * This only becomes an issue when using the 64bit compiler
24 * as the TASK_ID is no longer defined as an int.
26 return ::kill ((ACE_VX_TASK_ID)pid, signum);
28 return ::kill (pid, signum);
29 #endif /* ACE_LACKS_KILL */
33 pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp)
35 #if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_SIGMASK)
37 # ifdef ACE_PTHREAD_SIGMASK_MACRO
38 ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (ACE_PTHREAD_SIGMASK_MACRO (how, nsp, osp), result), int);
39 # elif defined (ACE_HAS_NONCONST_PTHREAD_SIGMASK)
40 sigset_t *ncnsp = const_cast<sigset_t *>(nsp);
41 ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, ncnsp, osp), result), int);
43 ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp), result), int);
44 # endif /* ACE_HAS_NONCONST__PTHREAD_SIGMASK */
45 #else /* !ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */
49 ACE_NOTSUP_RETURN (-1);
50 #endif /* ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */
54 sigaction (int signum, const ACE_SIGACTION *nsa, ACE_SIGACTION *osa)
56 ACE_OS_TRACE ("ACE_OS::sigaction");
59 #if defined (ACE_WIN32)
67 osa->sa_handler = ::signal (signum, SIG_IGN);
68 ::signal (signum, osa->sa_handler);
71 osa->sa_handler = ::signal (signum, nsa->sa_handler);
72 return osa->sa_handler == SIG_ERR ? -1 : 0;
73 #elif defined (ACE_LACKS_SIGACTION)
76 ACE_NOTSUP_RETURN (-1);
77 #elif !defined (ACE_HAS_SIGACTION_CONSTP2)
78 return ::sigaction (signum, const_cast<ACE_SIGACTION*> (nsa), osa);
80 return ::sigaction (signum, nsa, osa);
81 #endif /* ACE_WIN32 */
85 sigaddset (sigset_t *s, int signum)
87 ACE_OS_TRACE ("ACE_OS::sigaddset");
88 #if defined (ACE_LACKS_SIGSET)
94 else if (signum < 1 || signum >= ACE_NSIG)
97 return -1; // Invalid signum, return error
99 *s |= (1 << (signum - 1)) ;
102 return ace_sigaddset_helper (s, signum);
103 #endif /* ACE_LACKS_SIGSET */
107 sigdelset (sigset_t *s, int signum)
109 #if defined (ACE_LACKS_SIGSET)
115 else if (signum < 1 || signum >= ACE_NSIG)
118 return -1; // Invalid signum, return error
120 *s &= ~(1 << (signum - 1)) ;
123 return ace_sigdelset_helper (s, signum);
124 #endif /* ACE_LACKS_SIGSET */
128 sigemptyset (sigset_t *s)
130 #if defined (ACE_LACKS_SIGSET)
139 return ace_sigemptyset_helper (s);
140 #endif /* ACE_LACKS_SIGSET */
144 sigfillset (sigset_t *s)
146 #if defined (ACE_LACKS_SIGSET)
155 return ace_sigfillset_helper (s);
156 #endif /* ACE_LACKS_SIGSET */
160 sigismember (sigset_t *s, int signum)
162 #if defined (ACE_LACKS_SIGSET)
168 else if (signum < 1 || signum >= ACE_NSIG)
171 return -1; // Invalid signum, return error
173 return ((*s & (1 << (signum - 1))) != 0) ;
175 # if defined (ACE_HAS_SIGISMEMBER_BUG)
176 if (signum < 1 || signum >= ACE_NSIG)
179 return -1; // Invalid signum, return error
181 # endif /* ACE_HAS_SIGISMEMBER_BUG */
182 return ace_sigismember_helper (s, signum);
183 #endif /* ACE_LACKS_SIGSET */
186 ACE_INLINE ACE_SignalHandler
187 signal (int signum, ACE_SignalHandler func)
193 #if (defined ACE_WIN32) || \
194 (!defined ACE_LACKS_UNIX_SIGNALS && !defined ACE_LACKS_SIGNAL)
195 return ::signal (signum, func);
197 ACE_UNUSED_ARG (signum);
198 ACE_UNUSED_ARG (func);
199 ACE_NOTSUP_RETURN (0); // Should return SIG_ERR but maybe not defined on all platforms
200 #endif /* defined (ACE_WIN32) || !defined (ACE_LACKS_UNIX_SIGNALS) */
205 sigprocmask (int how, const sigset_t *nsp, sigset_t *osp)
207 #if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) || defined (ACE_LACKS_SIGPROCMASK)
208 ACE_UNUSED_ARG (how);
209 ACE_UNUSED_ARG (nsp);
210 ACE_UNUSED_ARG (osp);
211 ACE_NOTSUP_RETURN (-1);
213 return ::sigprocmask (how, nsp, osp);
214 #endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS || ACE_LACKS_SIGPROCMASK */
218 sigsuspend (const sigset_t *s)
220 #if defined (ACE_HAS_SIGSUSPEND)
225 ACE_OS::sigemptyset (&sigset);
228 return ace_sigsuspend_helper (s);
231 ACE_NOTSUP_RETURN (-1);
232 #endif /* ACE_HAS_SIGSUSPEND */
236 raise (const int signum)
238 #if defined (ACE_LACKS_RAISE)
239 ACE_UNUSED_ARG (signum);
240 ACE_NOTSUP_RETURN (-1);
242 return ::raise (signum);
243 #endif /* ACE_LACKS_RAISE */
246 } /* end namespace ACE_OS */
248 ACE_END_VERSIONED_NAMESPACE_DECL