1 /* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2002, 2007
2 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #include <hurd/signal.h>
26 /* Change the set of blocked signals to SET,
27 wait until a signal arrives, and restore the set of blocked signals. */
32 struct hurd_sigstate
*ss
;
33 sigset_t newmask
, oldmask
, pending
;
35 mach_msg_header_t msg
;
38 /* Crash before locking. */
41 /* Get a fresh port we will wait on. */
42 wait
= __mach_reply_port ();
44 ss
= _hurd_self_sigstate ();
46 __spin_lock (&ss
->lock
);
48 oldmask
= ss
->blocked
;
50 /* Change to the new blocked signal mask. */
51 ss
->blocked
= newmask
& ~_SIG_CANT_MASK
;
53 /* Notice if any pending signals just became unblocked. */
54 pending
= ss
->pending
& ~ss
->blocked
;
56 /* Tell the signal thread to message us when a signal arrives. */
58 __spin_unlock (&ss
->lock
);
61 /* Tell the signal thread to check for pending signals. */
62 __msg_sig_post (_hurd_msgport
, 0, 0, __mach_task_self ());
64 /* Wait for the signal thread's message. */
65 __mach_msg (&msg
, MACH_RCV_MSG
, 0, sizeof (msg
), wait
,
66 MACH_MSG_TIMEOUT_NONE
, MACH_PORT_NULL
);
67 __mach_port_destroy (__mach_task_self (), wait
);
69 __spin_lock (&ss
->lock
);
70 ss
->blocked
= oldmask
; /* Restore the old mask. */
71 pending
= ss
->pending
& ~ss
->blocked
; /* Again check for pending signals. */
72 __spin_unlock (&ss
->lock
);
75 /* Tell the signal thread to check for pending signals. */
76 __msg_sig_post (_hurd_msgport
, 0, 0, __mach_task_self ());
78 /* We've been interrupted! And a good thing, too.
79 Otherwise we'd never return.
80 That's right; this function always returns an error. */
84 libc_hidden_def (__sigsuspend
)
85 strong_alias (__sigsuspend
, sigsuspend_not_cancel
)
86 weak_alias (__sigsuspend
, sigsuspend
)