Added kill() implementation, user part of sigprocmask() now works.

Renamed syscalls.
Cleaned up files.
Removed unnecessary grist from source files.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8771 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-09-01 14:06:27 +00:00
parent d32f5c2e8b
commit 7800e87a5a
7 changed files with 86 additions and 82 deletions

View File

@ -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

View File

@ -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 <OS.h>
#include <signal.h>
#include <errno.h>
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;
}

View File

@ -1,24 +1,19 @@
#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()
*
* 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 <OS.h>
#include <signal.h>
int
raise(int sig)
{
return sys_send_signal(find_thread(NULL), sig);
{
return send_signal(find_thread(NULL), sig);
}

View File

@ -1,24 +1,19 @@
#include <syscalls.h>
#include <signal.h>
/*
* 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 <syscalls.h>
#include <signal.h>
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);
}

View File

@ -1,25 +1,19 @@
#include <syscalls.h>
#include <signal.h>
/*
* 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 <syscalls.h>
#include <signal.h>
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);
}

View File

@ -1,44 +1,37 @@
#include <syscalls.h>
/*
* 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 <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)
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;
}

View File

@ -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 <syscalls.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
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;
}