* Implemented sigaltstack() and set_signal_stack(), thus closing bug #1401.

* On exec() the new function thread_reset_for_exec() is called which clears the signals
  and cancels an eventually set alarm. Both things weren't done before...
* Some minor cleanups.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21989 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-08-16 18:01:47 +00:00
parent f2286d02b9
commit 0b70ea5992
13 changed files with 374 additions and 188 deletions
+9 -4
View File
@@ -21,10 +21,13 @@ status_t arch_team_init_team_struct(struct team *t, bool kernel);
status_t arch_thread_init_thread_struct(struct thread *t);
status_t arch_thread_init_tls(struct thread *thread);
void arch_thread_context_switch(struct thread *t_from, struct thread *t_to);
status_t arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void));
status_t arch_thread_init_kthread_stack(struct thread *t,
int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void));
void arch_thread_dump_info(void *info);
status_t arch_thread_enter_userspace(struct thread *t, addr_t entry, void *args1, void *args2);
void arch_thread_switch_kstack_and_call(struct thread *t, addr_t new_kstack, void (*func)(void *), void *arg);
status_t arch_thread_enter_userspace(struct thread *t, addr_t entry,
void *args1, void *args2);
void arch_thread_switch_kstack_and_call(struct thread *t, addr_t new_kstack,
void (*func)(void *), void *arg);
// ToDo: doing this this way is an ugly hack - please fix me!
// (those functions are "static inline" for x86 - since
@@ -34,7 +37,9 @@ struct thread *arch_thread_get_current_thread(void);
void arch_thread_set_current_thread(struct thread *t);
#endif
status_t arch_setup_signal_frame(struct thread *t, struct sigaction *sa, int sig, int sig_mask);
bool arch_on_signal_stack(struct thread *thread);
status_t arch_setup_signal_frame(struct thread *t, struct sigaction *sa,
int signal, int signalMask);
int64 arch_restore_signal_frame(void);
void arch_check_syscall_restart(struct thread *t);
+11 -8
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2003-2007, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_SIGNAL_H
@@ -22,15 +22,18 @@ extern bool is_kill_signal_pending(void);
extern int has_signals_pending(void *_thread);
extern int sigaction_etc(thread_id threadID, int signal,
const struct sigaction *act, struct sigaction *oldAction);
const struct sigaction *newAction, struct sigaction *oldAction);
extern int _user_send_signal(pid_t tid, uint sig);
extern int _user_sigprocmask(int how, const sigset_t *set, sigset_t *oldSet);
extern int _user_sigaction(int sig, const struct sigaction *action,
struct sigaction *oldAction);
extern status_t _user_send_signal(pid_t tid, uint sig);
extern status_t _user_sigprocmask(int how, const sigset_t *set,
sigset_t *oldSet);
extern status_t _user_sigaction(int sig, const struct sigaction *newAction,
struct sigaction *oldAction);
extern bigtime_t _user_set_alarm(bigtime_t time, uint32 mode);
extern int _user_sigsuspend(const sigset_t *mask);
extern int _user_sigpending(sigset_t *set);
extern status_t _user_sigsuspend(const sigset_t *mask);
extern status_t _user_sigpending(sigset_t *set);
extern status_t _user_set_signal_stack(const stack_t *newUserStack,
stack_t *oldUserStack);
#ifdef __cplusplus
}
+9 -5
View File
@@ -110,12 +110,16 @@ extern status_t _kern_get_next_team_info(int32 *cookie, team_info *info);
extern status_t _kern_get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size);
// signal functions
extern int _kern_send_signal(pid_t tid, uint sig);
extern int _kern_sigprocmask(int how, const sigset_t *set, sigset_t *oldSet);
extern int _kern_sigaction(int sig, const struct sigaction *action, struct sigaction *oldAction);
extern status_t _kern_send_signal(pid_t tid, uint sig);
extern status_t _kern_sigprocmask(int how, const sigset_t *set,
sigset_t *oldSet);
extern status_t _kern_sigaction(int sig, const struct sigaction *action,
struct sigaction *oldAction);
extern bigtime_t _kern_set_alarm(bigtime_t time, uint32 mode);
extern int _kern_sigsuspend(const sigset_t *mask);
extern int _kern_sigpending(sigset_t *set);
extern status_t _kern_sigsuspend(const sigset_t *mask);
extern status_t _kern_sigpending(sigset_t *set);
extern status_t _kern_set_signal_stack(const stack_t *newStack,
stack_t *oldStack);
// image functions
extern image_id _kern_register_image(image_info *info, size_t size);
+3 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2006, Axel Dörfler, [email protected].
* Copyright 2002-2007, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -23,11 +23,12 @@ extern "C" {
void thread_enqueue(struct thread *t, struct thread_queue *q);
struct thread *thread_lookat_queue(struct thread_queue *q);
struct thread *thread_dequeue(struct thread_queue *q);
struct thread *thread_dequeue_id(struct thread_queue *q, thread_id thr_id);
struct thread *thread_dequeue_id(struct thread_queue *q, thread_id id);
void thread_at_kernel_entry(void);
// called when the thread enters the kernel on behalf of the thread
void thread_at_kernel_exit(void);
void thread_reset_for_exec(void);
status_t thread_init(struct kernel_args *args);
status_t thread_preboot_init_percpu(struct kernel_args *args, int32 cpuNum);
+3
View File
@@ -140,6 +140,9 @@ struct thread {
sigset_t sig_pending;
sigset_t sig_block_mask;
struct sigaction sig_action[32];
addr_t signal_stack_base;
size_t signal_stack_size;
bool signal_stack_enabled;
bool in_kernel;
bool was_yielded;