diff --git a/src/kernel/libroot/posix/signal/raise.c b/src/kernel/libroot/posix/signal/raise.c new file mode 100644 index 0000000000..6aea0e0858 --- /dev/null +++ b/src/kernel/libroot/posix/signal/raise.c @@ -0,0 +1,26 @@ +#include +#include + +/* + * 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); +} + diff --git a/src/kernel/libroot/posix/signal/signal.c b/src/kernel/libroot/posix/signal/signal.c new file mode 100644 index 0000000000..f88d2771a4 --- /dev/null +++ b/src/kernel/libroot/posix/signal/signal.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +/* + * 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; + } + +} +