blob: 46fa22ca6401aa100c5bf9dc750858f49d76ff9d [file] [log] [blame]
njnde62cbf2005-06-10 22:08:14 +00001
2/*--------------------------------------------------------------------*/
3/*--- Signal-related libc stuff. pub_core_libcsignal.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
sewardj0f157dd2013-10-18 14:27:36 +000010 Copyright (C) 2000-2013 Julian Seward
njnde62cbf2005-06-10 22:08:14 +000011 jseward@acm.org
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __PUB_CORE_LIBCSIGNAL_H
32#define __PUB_CORE_LIBCSIGNAL_H
33
34//--------------------------------------------------------------------
35// PURPOSE: This module contains all the libc code related to signals.
36//--------------------------------------------------------------------
37
38#include "pub_tool_libcsignal.h"
39
sewardjc57bc142006-04-19 19:31:46 +000040/* Note that these use the vki_ (kernel) structure
41 definitions, which are different in places from those that glibc
42 defines. Since we're operating right at the kernel interface, glibc's view
43 of the world is entirely irrelevant. */
44
45/* --- Signal set ops --- */
46extern Int VG_(sigfillset) ( vki_sigset_t* set );
47extern Int VG_(sigemptyset) ( vki_sigset_t* set );
48
49extern Bool VG_(isfullsigset) ( const vki_sigset_t* set );
50extern Bool VG_(isemptysigset) ( const vki_sigset_t* set );
51extern Bool VG_(iseqsigset) ( const vki_sigset_t* set1,
52 const vki_sigset_t* set2 );
53
54extern Int VG_(sigaddset) ( vki_sigset_t* set, Int signum );
55extern Int VG_(sigdelset) ( vki_sigset_t* set, Int signum );
56extern Int VG_(sigismember) ( const vki_sigset_t* set, Int signum );
57
florian32971242014-10-23 17:47:15 +000058extern void VG_(sigaddset_from_set) ( vki_sigset_t* dst, const vki_sigset_t* src );
59extern void VG_(sigdelset_from_set) ( vki_sigset_t* dst, const vki_sigset_t* src );
60extern void VG_(sigintersectset) ( vki_sigset_t* dst, const vki_sigset_t* src );
61extern void VG_(sigcomplementset) ( vki_sigset_t* dst, const vki_sigset_t* src );
sewardjc57bc142006-04-19 19:31:46 +000062
63/* --- Mess with the kernel's sig state --- */
64/* VG_(sigprocmask) is in pub_tool_libcsignal.h. */
65
66extern Int VG_(sigaction) ( Int signum,
njncda2f0f2009-05-18 02:12:08 +000067 const vki_sigaction_toK_t* act,
68 vki_sigaction_fromK_t* oldact );
69
70/* Convert a sigaction which you got from the kernel (a _fromK_t) to
sewardj6e9de462011-06-28 07:25:29 +000071 one which you can give back to the kernel (a _toK_t). On Linux,
72 vki_sigaction_{toK,fromK}_t are identical, so this is a no-op
njncda2f0f2009-05-18 02:12:08 +000073 (structure copy), but on Darwin it's not a no-op. */
74extern void VG_(convert_sigaction_fromK_to_toK)(
florian32971242014-10-23 17:47:15 +000075 const vki_sigaction_fromK_t*, /*OUT*/vki_sigaction_toK_t*);
njncda2f0f2009-05-18 02:12:08 +000076
sewardjc57bc142006-04-19 19:31:46 +000077
sewardjc57bc142006-04-19 19:31:46 +000078extern Int VG_(kill) ( Int pid, Int signo );
njn99109fe2009-05-20 07:10:48 +000079extern Int VG_(tkill) ( Int lwpid, Int signo );
sewardjc57bc142006-04-19 19:31:46 +000080
sewardj1383bdd2006-10-17 01:30:47 +000081/* A cut-down version of POSIX sigtimedwait: poll for pending signals
82 mentioned in the sigset_t, and if any are present, select one
83 arbitrarily, return its number (which must be > 0), and put
84 auxiliary info about it in the siginfo_t, and make it
85 not-pending-any-more. If none are pending, return zero. The _zero
86 refers to the fact that there is zero timeout, so if no signals are
87 pending it returns immediately. Perhaps a better name would be
88 'sigpoll'. Returns -1 on error, 0 if no signals pending, and n > 0
89 if signal n was selected. */
90extern Int VG_(sigtimedwait_zero)( const vki_sigset_t *, vki_siginfo_t * );
sewardjc57bc142006-04-19 19:31:46 +000091
njnde62cbf2005-06-10 22:08:14 +000092#endif // __PUB_CORE_LIBCSIGNAL_H
93
94/*--------------------------------------------------------------------*/
95/*--- end ---*/
96/*--------------------------------------------------------------------*/