source: rtems/cpukit/posix/src/sigsuspend.c @ acfdf51

4.115
Last change on this file since acfdf51 was acfdf51, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 21, 2013 at 9:16:25 PM

sigsuspend.c: Address set but unused variable warning

  • Property mode set to 100644
File size: 1.5 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
37  /*
38   *  We use SIG_BLOCK and not SIG_SETMASK because there may be
39   *  signals which might be pending, which might get caught here.
40   *  We want the signals to be caught inside sigtimedwait.
41   *
42   *  We ignore the return status codes because sigsuspend() is
43   *  defined to either terminate or return -1 with errno set to
44   *  EINTR.
45   */
46  (void) sigprocmask( SIG_BLOCK, sigmask, &saved_signals_blocked );
47
48  current_unblocked_signals = ~(*sigmask);
49  (void) sigtimedwait( &current_unblocked_signals, NULL, NULL );
50
51  (void) sigprocmask( SIG_SETMASK, &saved_signals_blocked, NULL );
52
53  /*
54   * sigtimedwait() returns the signal number while sigsuspend()
55   * is supposed to return -1 and EINTR when a signal is caught.
56   */
57  #if defined(RTEMS_DEBUG)
58    assert( status != -1 );
59  #endif
60
61  rtems_set_errno_and_return_minus_one( EINTR );
62}
Note: See TracBrowser for help on using the repository browser.