|
Packit Service |
a2ae7a |
/* Convenience declarations when working with <signal.h>.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Copyright (C) 2008-2019 Free Software Foundation, Inc.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
a2ae7a |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
a2ae7a |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
a2ae7a |
(at your option) any later version.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
a2ae7a |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
a2ae7a |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
a2ae7a |
GNU General Public License for more details.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
a2ae7a |
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#ifndef _GL_SIG_HANDLER_H
|
|
Packit Service |
a2ae7a |
#define _GL_SIG_HANDLER_H
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#include <signal.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#ifndef _GL_INLINE_HEADER_BEGIN
|
|
Packit Service |
a2ae7a |
#error "Please include config.h first."
|
|
Packit Service |
a2ae7a |
#endif
|
|
Packit Service |
a2ae7a |
_GL_INLINE_HEADER_BEGIN
|
|
Packit Service |
a2ae7a |
#ifndef SIG_HANDLER_INLINE
|
|
Packit Service |
a2ae7a |
# define SIG_HANDLER_INLINE _GL_INLINE
|
|
Packit Service |
a2ae7a |
#endif
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Convenience type when working with signal handlers. */
|
|
Packit Service |
a2ae7a |
typedef void (*sa_handler_t) (int);
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Return the handler of a signal, as a sa_handler_t value regardless
|
|
Packit Service |
a2ae7a |
of its true type. The resulting function can be compared to
|
|
Packit Service |
a2ae7a |
special values like SIG_IGN but it is not portable to call it. */
|
|
Packit Service |
a2ae7a |
SIG_HANDLER_INLINE sa_handler_t _GL_ATTRIBUTE_PURE
|
|
Packit Service |
a2ae7a |
get_handler (struct sigaction const *a)
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
/* POSIX says that special values like SIG_IGN can only occur when
|
|
Packit Service |
a2ae7a |
action.sa_flags does not contain SA_SIGINFO. But in Linux 2.4,
|
|
Packit Service |
a2ae7a |
for example, sa_sigaction and sa_handler are aliases and a signal
|
|
Packit Service |
a2ae7a |
is ignored if sa_sigaction (after casting) equals SIG_IGN. In
|
|
Packit Service |
a2ae7a |
this case, this implementation relies on the fact that the two
|
|
Packit Service |
a2ae7a |
are aliases, and simply returns sa_handler. */
|
|
Packit Service |
a2ae7a |
return a->sa_handler;
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
_GL_INLINE_HEADER_END
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#endif /* _GL_SIG_HANDLER_H */
|