Patch by Vasilis Kaoutsis: Implemented sigignore(). Small changes by myself.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22789 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -163,6 +163,7 @@ int sigfillset(sigset_t *set);
|
|||||||
int sigaddset(sigset_t *set, int signo);
|
int sigaddset(sigset_t *set, int signo);
|
||||||
int sigdelset(sigset_t *set, int signo);
|
int sigdelset(sigset_t *set, int signo);
|
||||||
int sigismember(const sigset_t *set, int signo);
|
int sigismember(const sigset_t *set, int signo);
|
||||||
|
int sigignore(int signo);
|
||||||
|
|
||||||
const char *strsignal(int sig);
|
const char *strsignal(int sig);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ MergeObject posix_signal.o :
|
|||||||
set_signal_stack.c
|
set_signal_stack.c
|
||||||
sigaction.c
|
sigaction.c
|
||||||
sigaltstack.c
|
sigaltstack.c
|
||||||
|
sigignore.cpp
|
||||||
signal.c
|
signal.c
|
||||||
sigpending.c
|
sigpending.c
|
||||||
sigprocmask.c
|
sigprocmask.c
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007, Vasilis Kaoutsis, [email protected]
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
sigignore(int signal)
|
||||||
|
{
|
||||||
|
// check for invalid signals or for signals
|
||||||
|
// that can not be ignored (SIGKILL, SIGSTOP)
|
||||||
|
if (signal <= 0 || signal >= NSIG || signal == SIGKILL
|
||||||
|
|| signal == SIGSTOP) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sigaction ignoreSignalAction;
|
||||||
|
// create an action to ignore the signal
|
||||||
|
|
||||||
|
// request that the signal will be ignored
|
||||||
|
// by the handler of the action
|
||||||
|
ignoreSignalAction.sa_handler = SIG_IGN;
|
||||||
|
ignoreSignalAction.sa_flags = 0;
|
||||||
|
|
||||||
|
// In case of SIGCHLD the specification requires SA_NOCLDWAIT behavior.
|
||||||
|
if (signal == SIGCHLD)
|
||||||
|
ignoreSignalAction.sa_flags |= SA_NOCLDWAIT;
|
||||||
|
|
||||||
|
return sigaction(signal, &ignoreSignalAction, NULL);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user