source: rtems/cpukit/posix/src/sigsuspend.c @ 85c855af

4.115
Last change on this file since 85c855af was 85c855af, checked in by Chris Johns <chrisj@…>, on Sep 30, 2013 at 6:10:45 AM

Fix building with RTEMS_DEBUG.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief Replacing signal mask with *sigmask and suspending calling process
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  3.3.7 Wait for a Signal, P1003.1b-1993, p. 75
10 *
11 *  COPYRIGHT (c) 1989-2004.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <stddef.h>
24#include <assert.h>
25#include <signal.h>
26#include <errno.h>
27
28#include <rtems/seterr.h>
29
30int sigsuspend(
31  const sigset_t  *sigmask
32)
33{
34  sigset_t            saved_signals_blocked;
35  sigset_t            current_unblocked_signals;
36#if defined(RTEMS_DEBUG)
37    int                 status;
38#endif
39
40  /*
41   *  We use SIG_BLOCK and not SIG_SETMASK because there may be
42   *  signals which might be pending, which might get caught here.
43   *  We want the signals to be caught inside sigtimedwait.
44   *
45   *  We ignore the return status codes because sigsuspend() is
46   *  defined to either terminate or return -1 with errno set to
47   *  EINTR.
48   */
49#if defined(RTEMS_DEBUG)
50    status =
51#else
52  (void)
53#endif
54      sigprocmask( SIG_BLOCK, sigmask, &saved_signals_blocked );
55
56  current_unblocked_signals = ~(*sigmask);
57
58  #if defined(RTEMS_DEBUG)
59    status =
60#else
61  (void)
62#endif
63      sigtimedwait( &current_unblocked_signals, NULL, NULL );
64
65  (void) sigprocmask( SIG_SETMASK, &saved_signals_blocked, NULL );
66
67  /*
68   * sigtimedwait() returns the signal number while sigsuspend()
69   * is supposed to return -1 and EINTR when a signal is caught.
70   */
71  #if defined(RTEMS_DEBUG)
72    assert( status != -1 );
73  #endif
74
75  rtems_set_errno_and_return_minus_one( EINTR );
76}
Note: See TracBrowser for help on using the repository browser.