• Keine Ergebnisse gefunden

signals to be blocked while handler running

N/A
N/A
Protected

Academic year: 2022

Aktie "signals to be blocked while handler running"

Copied!
6
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Why POSIX Signals?

Problems with the signal() function:

• cannot determine the current action for a signal

; may change the action but not restore previous state

• in a signal handler, other signals cannot be blocked

; signal handler may be interrupted by other signals

• cannot block signals (delay delivery until unblock)

(2)

Data Structure

/* simplified from /usr/include/bits/sigaction.h */

struct sigaction {

/* pointer to handler function */

void(*)(int) sa_handler;

/* signals to be blocked while handler running */

sigset_t sa_mask;

/* flags normally set to 0 */

int sa_flags;

/* if SA_NOCLDSTOP

=> don’t send SIGCHLD when children stop. */

}

(3)

Manipulating a sigset t

A sigset t contains signals to be blocked.

int sigemptyset(sigset_t *set);

initialize (no signals to be blocked)

int sigfillset(sigset_t *set);

initialize (all signals to be blocked)

int sigaddset(sigset_t *set, int signum);

add signal number signum to the set

int sigdelset(sigset_t *set, int signum);

remove signal number signum from the set

int sigismember(const sigset_t *set, int signum);

return 1: signum is in the set

return 0: signum is not in the set

return -1: signum is an invalid signal number

(4)

Installing a Signal Handler

int sigaction(int signum,

const struct sigaction *act, struct sigaction *oldact);

signal handler for signum ;pointer act.

previous handler ;pointer oldact.

(5)

Temporarily Block Signals

During critical sections of code, the delivery of signals may be unwanted.

Set these according to a set via a call to

int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);

The previous list of blocked signals is saved in oldset.

The parameter how determines the following

how description

SIG_SET set is the new mask of blocked signals SIG_BLOCK set contains signals to be blocked

SIG_UNBLOCK set contains signals to be unblocked

(6)

Pending Signals

When a signal signum is sent while the process has blocked signum, the signal is said to be pending.

The signal will then be delivered after it is unblocked.

A process may get a mask of currently pending signals by calling int sigpending(sigset_t *set);

After the call, the memory pointed to by set contains the signals which are blocked and pending.

Referenzen

ÄHNLICHE DOKUMENTE

Jan Wörner argued for ‘Space for Youth!’ not only in the sense that space should serve the needs of youth, but also in the sense that space should make room for the young, should

Russian geo-political hard power may have trumped EU soft power in the short-run in both Armenia and Ukraine, but the democratic power of the Ukrainian people in alliance with

Coronary revascularization, either by CABG or PTCA, has been proven unequivocally to improve survival in selected patients, especially in those with triple vessel disease and

a certain graph, is shown, and he wants to understand what it means — this corre- sponds to reception, though it involves the understanding of a non-linguistic sign;

Die Produzenten von E-Only-Journals müssen sich den Herausforderungen der Langzeitar- chivierung elektronischer Ressourcen in verstärktem Maße stellen, da hier keine Archivie-

It focuses on the conception of austriacisms from different points of view according to linguistic experts, the analysis of the terms from the novel of Nöstlinger and most

The random process which corresponds to the describing model is said to be the process of heavy diffusion particles and denoted by X (t) = (X 1 (t),. Condition 4 ◦ ) means that

Diese oder eine ähnliche Frage muß man sich wohl als Studierender immer mal stellen. Wenn man die Zeichen der Zeit bzw. der demo- kratisch legitimierten Regierung zu