PosixSignals Linuximpl

Implements PosixSignals with help of POSIX interface.

Summary
PosixSignals LinuximplImplements PosixSignals with help of POSIX interface.
CopyrightThis program is free software.
Files
C-kern/api/platform/sync/signal.hHeader file of PosixSignals.
C-kern/platform/Linux/sync/signal.cLinux specific implementation PosixSignals Linuximpl.
Types
struct signalhandler_tExports signalhandler_t into global namespace.
signalhandler_tDescribes an overwritten signal handler.
isvalidIndicates if this structure contains valid information.
handlerFunction pointer to new signal handler.
oldstateContains old signal handler configuration.
s_signalhandlerStores global configuration information for signal handlers.
s_signalhandler_oldmaskStores old signal mask.
helper
dispatcher_signalhandlerThis signal handler is called for every signal.
clear_signalhandlerRestores the default signal handler of the platform.
set_signalhandlerOverwrites a previously set signal handler with sighandler.
setignore_signalhandlerSets signal handler which consumes and ignores signal signr.
init
query
change
signalstate_tSystem specific declaration.
nr_signal_handlersNumber of stored signal handlers.
signalmaskThe signal mask of the current thread.
signal_handlersStores setting for every signal handler.
helper
nrhandlers_signalstateReturns the number of valid signal handlers.
objectsize_signalstateReturns size in bytes needed to store a single signalstate_t.
lifetime
query
signalwait_t
lifetime
free_signalwaitFrees all resources associated with signalwait.
signalrt_t
query
change
test

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2011 Jörg Seebohn

Files

C-kern/api/platform/sync/signal.h

Header file of PosixSignals.

C-kern/platform/Linux/sync/signal.c

Linux specific implementation PosixSignals Linuximpl.

Types

struct signalhandler_t

typedef struct signalhandler_t signalhandler_t

Exports signalhandler_t into global namespace.

signalhandler_t

struct signalhandler_t

Describes an overwritten signal handler.

Summary
isvalidIndicates if this structure contains valid information.
handlerFunction pointer to new signal handler.
oldstateContains old signal handler configuration.
s_signalhandlerStores global configuration information for signal handlers.
s_signalhandler_oldmaskStores old signal mask.
helper
dispatcher_signalhandlerThis signal handler is called for every signal.
clear_signalhandlerRestores the default signal handler of the platform.
set_signalhandlerOverwrites a previously set signal handler with sighandler.
setignore_signalhandlerSets signal handler which consumes and ignores signal signr.
init
query
change

isvalid

bool isvalid

Indicates if this structure contains valid information.

handler

signalhandler_f handler

Function pointer to new signal handler.

oldstate

struct sigaction oldstate

Contains old signal handler configuration.  This value is set in initonce_signalhandler before the signal handler is overwritten.

s_signalhandler

static signalhandler_t s_signalhandler[64]

Stores global configuration information for signal handlers.  See signalhandler_t.  All values in the array are set in initonce_signalhandler.

s_signalhandler_oldmask

static sigset_t s_signalhandler_oldmask

Stores old signal mask.  This value is set in initonce_signalhandler before the signal mask is changed.

helper

dispatcher_signalhandler

static void dispatcher_signalhandler(int signr,
siginfo_t *siginfo,
void *ucontext)

This signal handler is called for every signal.  It dispatches handling of the signal to the set signal handler.

clear_signalhandler

static int clear_signalhandler(unsigned signr)

Restores the default signal handler of the platform.

set_signalhandler

static int set_signalhandler(unsigned signr,
signalhandler_f sighandler)

Overwrites a previously set signal handler with sighandler.

setignore_signalhandler

static int setignore_signalhandler(unsigned signr)

Sets signal handler which consumes and ignores signal signr.

init

query

change

signalstate_t

struct signalstate_t

System specific declaration.

Summary
nr_signal_handlersNumber of stored signal handlers.
signalmaskThe signal mask of the current thread.
signal_handlersStores setting for every signal handler.
helper
nrhandlers_signalstateReturns the number of valid signal handlers.
objectsize_signalstateReturns size in bytes needed to store a single signalstate_t.
lifetime
query

nr_signal_handlers

int nr_signal_handlers

Number of stored signal handlers.

signalmask

sigset_t signalmask

The signal mask of the current thread.

signal_handlers

struct sigaction signal_handlers[/*nr_signal_handlers*/]

Stores setting for every signal handler.

helper

nrhandlers_signalstate

static int nrhandlers_signalstate(void)

Returns the number of valid signal handlers.  Linux supports signals numbers from 1 to 31 and from SIGRTMIN to SIGRTMAX.

objectsize_signalstate

static size_t objectsize_signalstate(void)

Returns size in bytes needed to store a single signalstate_t.

lifetime

query

signalwait_t

Summary
lifetime
free_signalwaitFrees all resources associated with signalwait.

lifetime

free_signalwait

int free_signalwait(signalwait_t *signalwait)

Frees all resources associated with signalwait.  After return the iochannel_t returned from io_signalwait is invalid.

signalrt_t

query

change

test

Implements PosixSignals with help of POSIX interface.
typedef struct signalhandler_t signalhandler_t
Exports signalhandler_t into global namespace.
struct signalhandler_t
Describes an overwritten signal handler.
bool isvalid
Indicates if this structure contains valid information.
signalhandler_f handler
Function pointer to new signal handler.
struct sigaction oldstate
Contains old signal handler configuration.
static signalhandler_t s_signalhandler[64]
Stores global configuration information for signal handlers.
static sigset_t s_signalhandler_oldmask
Stores old signal mask.
static void dispatcher_signalhandler(int signr,
siginfo_t *siginfo,
void *ucontext)
This signal handler is called for every signal.
static int clear_signalhandler(unsigned signr)
Restores the default signal handler of the platform.
static int set_signalhandler(unsigned signr,
signalhandler_f sighandler)
Overwrites a previously set signal handler with sighandler.
static int setignore_signalhandler(unsigned signr)
Sets signal handler which consumes and ignores signal signr.
struct signalstate_t
System specific declaration.
int nr_signal_handlers
Number of stored signal handlers.
sigset_t signalmask
The signal mask of the current thread.
struct sigaction signal_handlers[/*nr_signal_handlers*/]
Stores setting for every signal handler.
static int nrhandlers_signalstate(void)
Returns the number of valid signal handlers.
static size_t objectsize_signalstate(void)
Returns size in bytes needed to store a single signalstate_t.
int free_signalwait(signalwait_t *signalwait)
Frees all resources associated with signalwait.
int initonce_signalhandler(void)
Sets up a process wide signal handler and signal masks at process initialization.
typedef sys_iochannel_t iochannel_t
Describes an input/output channel like a file or network connection.
#define io_signalwait(signalwait) ((sys_iochannel_t)signalwait)
Implement signalwait_t.io_signalwait.
Close