2007-11-27

sigset

關於收到 signal 時的處理。

SYNOPSIS

#include

void(*sigset(int sig, void (*disp)(int)))(int);
DESCRIPTION

The sigset() function is used to modify signal disposition by handling receipt of the signal number sig in one of three ways: taking the default action for the signal, ignoring the signal, or catching the signal. If the value of disp is SIG_DFL, default handling for that signal occurs. If the value of disp is SIG_IGN, the signal is ignored. Otherwise, disp points to a function (a signal handler) to be called when that signal occurs.

If disp is the address of the signal handler, the system adds sig to the signal mask of the calling process before executing the signal handler. When the signal handler returns, the system restores the signal mask of the calling process to its state prior to delivering the signal. If disp is SIG_HOLD, the system adds sig to the signal mask of the calling process and leaves the signal's disposition unchanged.

If sigset() is used to set the disposition of SIGCHLD to a signal handler, SIGCHLD is not sent when the children of the calling process are stopped or continued.

If sigset() is used to set the disposition of SIGCHLD to SIG_IGN, the child processes of the calling process does not create zombie processes when they terminate. If the calling process subsequently waits for its children, it blocks until all of its children terminate; it then returns a value of -1 with errno set to ECHILD.
PARAMETERS

sig

Specifies the signal, which may be any signal except SIGKILL or SIGSTOP.
disp

Specifies the signal's disposition, which may be SIG_DFL, SIG_HOLD, SIG_IGN, or the address of a signal handler.

RETURN VALUES

sigset() returns SIG_HOLD if the signal had been blocked, or it returns the signal's previous disposition if it had not been blocked. On failure, it returns SIG_ERR and sets errno to one of the following values:

EINVAL

The value of sig is not a valid signal or is equal to SIGKILL or SIGSTOP.

原文

沒有留言:

張貼留言