fix mcexec SIG_IGN

This commit is contained in:
Tomoki Shirasawa
2015-02-12 19:02:58 +09:00
parent d21ae28843
commit 0e0bc548f6
2 changed files with 60 additions and 5 deletions

View File

@ -811,6 +811,8 @@ static void *main_loop_thread_func(void *arg)
return NULL;
}
#define LOCALSIG SIGCHLD
void
sendsig(int sig, siginfo_t *siginfo, void *context)
{
@ -822,7 +824,10 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
struct signal_desc sigdesc;
if(siginfo->si_pid == pid &&
siginfo->si_signo == SIGINT)
siginfo->si_signo == LOCALSIG)
return;
if(siginfo->si_signo == SIGCHLD)
return;
for(i = 0; i < ncpu; i++){
@ -860,6 +865,34 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
}
}
void
act_sigaction(struct syscall_wait_desc *w)
{
struct sigaction act;
int sig;
sig = w->sr.args[0];
memset(&act, '\0', sizeof act);
if (w->sr.args[1] == -1)
act.sa_handler = SIG_IGN;
else{
act.sa_sigaction = sendsig;
act.sa_flags = SA_SIGINFO;
}
sigaction(sig, &act, NULL);
}
void
act_sigprocmask(struct syscall_wait_desc *w)
{
sigset_t set;
sigemptyset(&set);
memcpy(&set, &w->sr.args[0], sizeof(unsigned long));
sigdelset(&set, LOCALSIG);
sigprocmask(SIG_SETMASK, &set, NULL);
}
static int reduce_stack(struct rlimit *orig_rlim, char *argv[])
{
int n;
@ -912,8 +945,7 @@ void init_sigaction(void)
master_tid = gettid();
for (i = 1; i <= 64; i++) {
if (i != SIGCHLD && i != SIGCONT && i != SIGSTOP &&
i != SIGTSTP && i != SIGTTIN && i != SIGTTOU) {
if (i != SIGKILL && i != SIGSTOP) {
struct sigaction act;
sigaction(i, NULL, &act);
@ -1335,13 +1367,13 @@ static void
kill_thread(unsigned long cpu)
{
if(cpu >= 0 && cpu < ncpu){
pthread_kill(thread_data[cpu].thread_id, SIGINT);
pthread_kill(thread_data[cpu].thread_id, LOCALSIG);
}
else{
int i;
for (i = 0; i < ncpu; ++i) {
pthread_kill(thread_data[i].thread_id, SIGINT);
pthread_kill(thread_data[i].thread_id, LOCALSIG);
}
}
}
@ -1846,6 +1878,16 @@ return_execve2:
break;
}
case __NR_rt_sigaction:
act_sigaction(&w);
do_syscall_return(fd, cpu, 0, 0, 0, 0, 0);
break;
case __NR_rt_sigprocmask:
act_sigprocmask(&w);
do_syscall_return(fd, cpu, 0, 0, 0, 0, 0);
break;
case __NR_close:
if(w.sr.args[0] == fd)
ret = -EBADF;

View File

@ -1956,6 +1956,7 @@ do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
struct process *proc = cpu_local_var(current);
struct k_sigaction *k;
int irqstate;
ihk_mc_user_context_t ctx0;
irqstate = ihk_mc_spinlock_lock(&proc->sighandler->lock);
k = proc->sighandler->action + sig - 1;
@ -1964,6 +1965,13 @@ do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
if(act)
memcpy(k, act, sizeof(struct k_sigaction));
ihk_mc_spinlock_unlock(&proc->sighandler->lock, irqstate);
if(act){
ihk_mc_syscall_arg0(&ctx0) = sig;
ihk_mc_syscall_arg1(&ctx0) = (unsigned long)act->sa.sa_handler;
ihk_mc_syscall_arg2(&ctx0) = act->sa.sa_flags;
syscall_generic_forwarding(__NR_rt_sigaction, &ctx0);
}
return 0;
}
@ -1976,6 +1984,7 @@ SYSCALL_DECLARE(rt_sigprocmask)
struct process *proc = cpu_local_var(current);
int flag;
__sigset_t wsig;
ihk_mc_user_context_t ctx0;
if(sigsetsize != sizeof(sigset_t))
return -EINVAL;
@ -2007,7 +2016,11 @@ SYSCALL_DECLARE(rt_sigprocmask)
break;
}
}
wsig = proc->sigmask.__val[0];
ihk_mc_spinlock_unlock(&proc->sighandler->lock, flag);
ihk_mc_syscall_arg0(&ctx0) = wsig;
syscall_generic_forwarding(__NR_rt_sigprocmask, &ctx0);
return 0;
fault:
ihk_mc_spinlock_unlock(&proc->sighandler->lock, flag);