replaced sys_kill with general thread-aimed sys_send_signal; cleaned up
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1740 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -61,7 +61,7 @@ status_t sys_get_next_thread_info(team_id team, int32 *cookie, thread_info *info
|
||||
status_t sys_get_team_info(team_id id, team_info *info);
|
||||
status_t sys_get_next_team_info(int32 *cookie, team_info *info);
|
||||
|
||||
int sys_kill(pid_t pid, int sig);
|
||||
int sys_send_signal(pid_t tid, uint sig);
|
||||
int sys_sigaction(int sig, const struct sigaction *act, struct sigaction *oact);
|
||||
bigtime_t sys_set_alarm(bigtime_t time, uint32 mode);
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ enum {
|
||||
SYSCALL_REMOVE_ATTR,
|
||||
SYSCALL_RENAME_ATTR,
|
||||
SYSCALL_RETURN_FROM_SIGNAL,
|
||||
SYSCALL_KILL,
|
||||
SYSCALL_KILL, // obsolete
|
||||
SYSCALL_SIGACTION, /* 105 */
|
||||
SYSCALL_OPEN_INDEX_DIR,
|
||||
SYSCALL_CREATE_INDEX,
|
||||
|
||||
@@ -21,7 +21,7 @@ void start_scheduler(void);
|
||||
|
||||
#define BLOCKABLE_SIGS (~((1L << (SIGKILL - 1)) | (1L << (SIGSTOP - 1))))
|
||||
|
||||
void handle_signals(struct thread *t, int state);
|
||||
int handle_signals(struct thread *t, int state);
|
||||
|
||||
void thread_enqueue(struct thread *t, struct thread_queue *q);
|
||||
struct thread *thread_lookat_queue(struct thread_queue *q);
|
||||
|
||||
@@ -195,7 +195,7 @@ int cmd_kill(int argc, char *argv[])
|
||||
printf("not enough arguments to kill\n");
|
||||
return 0;
|
||||
}
|
||||
rc = sys_kill(atoi(argv[2]), atoi(argv[1]));
|
||||
rc = sys_send_signal(atoi(argv[2]), atoi(argv[1]));
|
||||
if (rc)
|
||||
printf("kill failed\n");
|
||||
return 0;
|
||||
|
||||
@@ -25,11 +25,11 @@ const char * const sys_siglist[NSIG] = {
|
||||
|
||||
|
||||
// Expects interrupts off and thread lock held.
|
||||
void
|
||||
int
|
||||
handle_signals(struct thread *t, int state)
|
||||
{
|
||||
uint32 sig_mask = t->sig_pending & (~t->sig_block_mask);
|
||||
int i, sig;
|
||||
int i, sig, global_resched = 0;
|
||||
struct sigaction *handler;
|
||||
|
||||
if (sig_mask) {
|
||||
@@ -61,6 +61,7 @@ handle_signals(struct thread *t, int state)
|
||||
|
||||
case SIGSTOP:
|
||||
t->next_state = B_THREAD_SUSPENDED;
|
||||
global_resched = 1;
|
||||
continue;
|
||||
|
||||
case SIGQUIT:
|
||||
@@ -90,12 +91,13 @@ handle_signals(struct thread *t, int state)
|
||||
if (!(handler->sa_flags & SA_NOMASK))
|
||||
t->sig_block_mask |= (handler->sa_mask | (1L << sig)) & BLOCKABLE_SIGS;
|
||||
|
||||
return;
|
||||
return global_resched;
|
||||
} else
|
||||
sig_mask >>= 1;
|
||||
}
|
||||
arch_check_syscall_restart(t);
|
||||
}
|
||||
return global_resched;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,30 +189,6 @@ has_signals_pending(void *thr)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sys_kill(pid_t pid, int sig)
|
||||
{
|
||||
struct team *t;
|
||||
int state;
|
||||
thread_id tid = -1;
|
||||
|
||||
// XXX check for permissions
|
||||
|
||||
state = disable_interrupts();
|
||||
GRAB_THREAD_LOCK();
|
||||
t = team_get_team_struct_locked(pid);
|
||||
if ((t) && (t->main_thread))
|
||||
tid = t->main_thread->id;
|
||||
RELEASE_THREAD_LOCK();
|
||||
restore_interrupts(state);
|
||||
|
||||
if (sig)
|
||||
return send_signal_etc(tid, sig, 0);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
user_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
|
||||
{
|
||||
|
||||
@@ -389,9 +389,6 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re
|
||||
case SYSCALL_RETURN_FROM_SIGNAL:
|
||||
*call_ret = arch_restore_signal_frame();
|
||||
break;
|
||||
case SYSCALL_KILL:
|
||||
*call_ret = sys_kill((pid_t)arg0, (int)arg1);
|
||||
break;
|
||||
case SYSCALL_SIGACTION:
|
||||
*call_ret = user_sigaction((int)arg0, (const struct sigaction *)arg1, (struct sigaction *)arg2);
|
||||
break;
|
||||
|
||||
@@ -471,12 +471,7 @@ thread_create_kernel_thread_etc(const char *name, int (*func)(void *), void *arg
|
||||
int
|
||||
thread_suspend_thread(thread_id id)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = send_signal_etc(id, SIGSTOP, B_DO_NOT_RESCHEDULE);
|
||||
if (rv == B_OK)
|
||||
smp_send_broadcast_ici(SMP_MSG_RESCHEDULE, 0, 0, 0, NULL, SMP_MSG_FLAG_SYNC);
|
||||
return rv;
|
||||
return send_signal_etc(id, SIGSTOP, B_DO_NOT_RESCHEDULE);
|
||||
}
|
||||
|
||||
|
||||
@@ -1241,7 +1236,7 @@ thread_atkernel_entry(void)
|
||||
void
|
||||
thread_atkernel_exit(void)
|
||||
{
|
||||
int state;
|
||||
int state, global_resched;
|
||||
struct thread *t;
|
||||
bigtime_t now;
|
||||
|
||||
@@ -1252,18 +1247,20 @@ thread_atkernel_exit(void)
|
||||
state = disable_interrupts();
|
||||
GRAB_THREAD_LOCK();
|
||||
|
||||
handle_signals(t, state);
|
||||
global_resched = handle_signals(t, state);
|
||||
|
||||
t->in_kernel = false;
|
||||
|
||||
RELEASE_THREAD_LOCK();
|
||||
|
||||
// track kernel time
|
||||
now = system_time();
|
||||
t->kernel_time += now - t->last_time;
|
||||
t->last_time = now;
|
||||
|
||||
RELEASE_THREAD_LOCK();
|
||||
restore_interrupts(state);
|
||||
|
||||
if (global_resched)
|
||||
smp_send_broadcast_ici(SMP_MSG_RESCHEDULE, 0, 0, 0, NULL, SMP_MSG_FLAG_SYNC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -152,7 +152,6 @@ SYSCALL2(sys_getenv, 80)
|
||||
|
||||
/* Signal handling calls */
|
||||
SYSCALL0(sys_return_from_signal, 103)
|
||||
SYSCALL2(sys_kill, 104)
|
||||
SYSCALL3(sys_sigaction, 105)
|
||||
SYSCALL2(sys_send_signal, 110)
|
||||
SYSCALL3(sys_set_alarm, 111)
|
||||
|
||||
@@ -83,14 +83,14 @@ set_thread_priority(thread_id thread, int32 priority)
|
||||
void
|
||||
exit_thread(status_t status)
|
||||
{
|
||||
// ToDo: exit_thread not implemented
|
||||
sys_exit(status);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
wait_for_thread(thread_id thread, status_t *thread_return_value)
|
||||
{
|
||||
return sys_wait_on_thread(thread,thread_return_value);
|
||||
return sys_wait_on_thread(thread, thread_return_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user