diff --git a/src/kernel/libroot/posix/signal/Jamfile b/src/kernel/libroot/posix/signal/Jamfile index 7d5f6a514b..8c5f335768 100644 --- a/src/kernel/libroot/posix/signal/Jamfile +++ b/src/kernel/libroot/posix/signal/Jamfile @@ -1,15 +1,15 @@ SubDir OBOS_TOP src kernel libroot posix signal ; KernelMergeObject posix_signal.o : - <$(SOURCE_GRIST)>raise.c - <$(SOURCE_GRIST)>send_signal.c - <$(SOURCE_GRIST)>sigaction.c - <$(SOURCE_GRIST)>signal.c - <$(SOURCE_GRIST)>sigprocmask.c - <$(SOURCE_GRIST)>sigset.c - <$(SOURCE_GRIST)>strsignal.c - : - -fPIC -DPIC + kill.c + raise.c + send_signal.c + sigaction.c + signal.c + sigprocmask.c + sigset.c + strsignal.c + : -fPIC -DPIC ; # there are no files in the kernel diff --git a/src/kernel/libroot/posix/signal/kill.c b/src/kernel/libroot/posix/signal/kill.c new file mode 100644 index 0000000000..7932e0c2cb --- /dev/null +++ b/src/kernel/libroot/posix/signal/kill.c @@ -0,0 +1,23 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include + +#include +#include + + +int +kill(pid_t pid, int sig) +{ + status_t status = send_signal(pid, (uint)sig); + if (status < B_OK) { + errno = status; + return -1; + } + + return 0; +} diff --git a/src/kernel/libroot/posix/signal/raise.c b/src/kernel/libroot/posix/signal/raise.c index e0569a6bb2..6b22eb39b9 100644 --- a/src/kernel/libroot/posix/signal/raise.c +++ b/src/kernel/libroot/posix/signal/raise.c @@ -1,24 +1,19 @@ -#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() - * + * Copyright (c) 2002-2004, Haiku Project. All rights reserved. + * Distributed under the terms of the Haiku license. * * Author(s): * Daniel Reinhold (danielre@users.sf.net) - * */ +#include +#include + + int raise(int sig) -{ - return sys_send_signal(find_thread(NULL), sig); +{ + return send_signal(find_thread(NULL), sig); } diff --git a/src/kernel/libroot/posix/signal/send_signal.c b/src/kernel/libroot/posix/signal/send_signal.c index fb63a4a7eb..06482aa0cd 100644 --- a/src/kernel/libroot/posix/signal/send_signal.c +++ b/src/kernel/libroot/posix/signal/send_signal.c @@ -1,24 +1,19 @@ -#include -#include - /* - * Copyright (c) 2002, OpenBeOS Project. All rights reserved. - * Distributed under the terms of the OpenBeOS license. - * - * send_signal.c: - * implements the signal function send_signal() - * this is merely a wrapper for a syscall - * + * Copyright (c) 2002-2004, Haiku Project. All rights reserved. + * Distributed under the terms of the Haiku license. * * Author(s): * Daniel Reinhold (danielre@users.sf.net) - * */ +#include +#include + + int -send_signal(pid_t tid, uint sig) +send_signal(pid_t thread, uint sig) { - return sys_send_signal(tid, sig); + return _kern_send_signal(thread, sig); } diff --git a/src/kernel/libroot/posix/signal/sigaction.c b/src/kernel/libroot/posix/signal/sigaction.c index 8658352d93..ff6b4fb18a 100644 --- a/src/kernel/libroot/posix/signal/sigaction.c +++ b/src/kernel/libroot/posix/signal/sigaction.c @@ -1,25 +1,19 @@ -#include -#include - /* - * Copyright (c) 2002, OpenBeOS Project. All rights reserved. - * Distributed under the terms of the OpenBeOS license. - * - * - * sigaction.c: - * implements the signal function sigaction() - * this is merely a wrapper for a syscall - * + * Copyright (c) 2002-2004, Haiku Project. All rights reserved. + * Distributed under the terms of the Haiku license. * * Author(s): * Daniel Reinhold (danielre@users.sf.net) - * */ +#include +#include + + int -sigaction(int sig, const struct sigaction *act, struct sigaction *oact) +sigaction(int sig, const struct sigaction *action, struct sigaction *oldAction) { - return sys_sigaction(sig, act, oact); + return _kern_sigaction(sig, action, oldAction); } diff --git a/src/kernel/libroot/posix/signal/signal.c b/src/kernel/libroot/posix/signal/signal.c index f88d2771a4..07dc4cc8ea 100644 --- a/src/kernel/libroot/posix/signal/signal.c +++ b/src/kernel/libroot/posix/signal/signal.c @@ -1,44 +1,37 @@ -#include +/* + * Copyright (c) 2002-2004, Haiku Project. All rights reserved. + * Distributed under the terms of the Haiku license. + * + * Author(s): + * Daniel Reinhold (danielre@users.sf.net) + */ + + #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) +signal(int sig, sig_func_t signalHandler) { + struct sigaction newAction, oldAction; int err; - struct sigaction repl, orig; - + // setup the replacement sigaction - repl.sa_handler = signal_handler; - repl.sa_mask = 0; - repl.sa_flags = 0; - + newAction.sa_handler = signalHandler; + newAction.sa_mask = 0; + newAction.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 { + err = sigaction(sig, &newAction, &oldAction); + if (err < B_OK) { errno = err; return SIG_ERR; } + // success, return the original handler + return oldAction.sa_handler; } diff --git a/src/kernel/libroot/posix/signal/sigprocmask.c b/src/kernel/libroot/posix/signal/sigprocmask.c index 536e852709..dcf2dfe428 100644 --- a/src/kernel/libroot/posix/signal/sigprocmask.c +++ b/src/kernel/libroot/posix/signal/sigprocmask.c @@ -1,4 +1,4 @@ -/* +/* ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. ** Distributed under the terms of the Haiku License. */ @@ -7,14 +7,18 @@ #include #include -#include +#include int -sigprocmask(int how, const sigset_t *set, sigset_t *oset) +sigprocmask(int how, const sigset_t *set, sigset_t *oldSet) { - // ToDo: implement me! - fprintf(stderr, "sigprocmask(): NOT IMPLEMENTED\n"); - return -1; +/* int status = sigprocmask(how, set, oldSet); + if (status < B_OK) { + errno = status; + return -1; + } +*/ + return 0; }