added raise() and signal()
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1998 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
715f76df9e
commit
274dff2fe0
26
src/kernel/libroot/posix/signal/raise.c
Normal file
26
src/kernel/libroot/posix/signal/raise.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <syscalls.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002, OpenBeOS Project. All rights reserved.
|
||||
* Distributed under the terms of the OpenBeOS license.
|
||||
*
|
||||
*
|
||||
* raise.c:
|
||||
* implements the signal function raise()
|
||||
*
|
||||
*
|
||||
* Author(s):
|
||||
* Daniel Reinhold (danielre@users.sf.net)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
raise(int sig)
|
||||
{
|
||||
thread_id tid = sys_get_current_thread_id();
|
||||
|
||||
return sys_send_signal(tid, sig);
|
||||
}
|
||||
|
44
src/kernel/libroot/posix/signal/signal.c
Normal file
44
src/kernel/libroot/posix/signal/signal.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include <syscalls.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002, OpenBeOS Project. All rights reserved.
|
||||
* Distributed under the terms of the OpenBeOS license.
|
||||
*
|
||||
*
|
||||
* signal.c:
|
||||
* implements the standard C library function signal()
|
||||
*
|
||||
*
|
||||
* Author(s):
|
||||
* Daniel Reinhold (danielre@users.sf.net)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
sig_func_t
|
||||
signal(int sig, sig_func_t signal_handler)
|
||||
{
|
||||
int err;
|
||||
struct sigaction repl, orig;
|
||||
|
||||
// setup the replacement sigaction
|
||||
repl.sa_handler = signal_handler;
|
||||
repl.sa_mask = 0;
|
||||
repl.sa_flags = 0;
|
||||
|
||||
// install the replacement sigaction for the signal 'sig' into
|
||||
// the current thread (the original is copied into the last param)
|
||||
err = sys_sigaction(sig, &repl, &orig);
|
||||
if (err == 0)
|
||||
// success, return the original handler
|
||||
return orig.sa_handler;
|
||||
else {
|
||||
errno = err;
|
||||
return SIG_ERR;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user