#include <lunaix/syscall.h>
#include <lunaix/syslog.h>
-LOG_MODULE("SIG")
-
#include <klibc/string.h>
+#include <sys/mm/mempart.h>
+
+LOG_MODULE("SIG")
+
extern struct scheduler sched_ctx; /* kernel/sched.c */
#define UNMASKABLE (sigset(SIGKILL) | sigset(SIGTERM))
#define TERMSIG (sigset(SIGSEGV) | sigset(SIGINT) | UNMASKABLE)
#define CORE (sigset(SIGSEGV))
+#define within_kstack(addr) \
+ (KERNEL_STACK <= (addr) && (addr) <= KERNEL_STACK_END)
static inline void
signal_terminate(int errcode)
struct sigact* prev_working = psig->inprogress;
sigset_t mask = psig->sig_mask | (prev_working ? prev_working->sa_mask : 0);
- int sig_selected = 31 - __builtin_clz(psig->sig_pending & ~mask);
+ int sig_selected = 31 - clz(psig->sig_pending & ~mask);
sigset_clear(psig->sig_pending, sig_selected);
ptr_t ustack = __current->ustack_top;
- if ((int)(ustack - USTACK_END) < (int)sizeof(struct proc_sig)) {
+ if ((int)(ustack - USR_STACK) < (int)sizeof(struct proc_sig)) {
// 用户栈没有空间存放信号上下文
return 0;
}
struct proc_sig* sigframe =
- (struct proc_sig*)((ustack - sizeof(struct proc_sig)) & ~0xf);
+ (struct proc_sig*)((ustack - sizeof(struct proc_sig)) & ~0xf);
sigframe->sig_num = sig_selected;
sigframe->sigact = action->sa_actor;
return sigframe;
}
+void
+proc_clear_signal(struct proc_info* proc)
+{
+ memset(&proc->sigctx, 0, sizeof(proc->sigctx));
+}
+
void
proc_setsignal(struct proc_info* proc, int signum)
{
} else if (!pid) {
proc = __current;
goto send_grp;
- } else if (pid < -1) {
+ } else if (pid < 0) {
proc = get_process(-pid);
goto send_grp;
} else {
return 0;
}
-__DEFINE_LXSYSCALL3(int,
- sigprocmask,
- int,
- how,
- const sigset_t,
- *set,
- sigset_t,
- *oldset)
+__DEFINE_LXSYSCALL3(
+ int, sigprocmask, int, how, const sigset_t, *set, sigset_t, *oldset)
{
struct sighail* sh = &__current->sigctx;
*oldset = sh->sig_mask;