Commit caf87545 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

signal: fix logig about SIGMAX (v2)

A value of signo is in [1, SIGMAX].
Currenly signals are enumirated from 1 to SIGMAX, but SIGMAX
is not included. This patch fixes this mestake.

v2: * save backward compatibility
    * set a correct value of SIGMAX = 64. It can not be in a
    separate patch, because a format is changed again.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 360c50d4
......@@ -520,11 +520,20 @@ static int prepare_sigactions(int pid)
if (fd_sigact < 0)
return -1;
for (sig = 1; sig < SIGMAX; sig++) {
for (sig = 1; sig <= SIGMAX; sig++) {
if (sig == SIGKILL || sig == SIGSTOP)
continue;
ret = pb_read_one(fd_sigact, &e, PB_SIGACT);
ret = pb_read_one_eof(fd_sigact, &e, PB_SIGACT);
if (ret == 0) {
if (sig != SIGMAX_OLD + 1) { /* backward compatibility */
pr_err("Unexpected EOF %d\n", sig);
ret = -1;
break;
}
pr_warn("This format of sigacts-%d.img is depricated\n", pid);
break;
}
if (ret < 0)
break;
......@@ -618,7 +627,7 @@ static void zombie_prepare_signals(void)
memset(&act, 0, sizeof(act));
act.sa_handler = SIG_DFL;
for (sig = 1; sig < SIGMAX; sig++)
for (sig = 1; sig <= SIGMAX; sig++)
sigaction(sig, &act, NULL);
}
......@@ -653,7 +662,7 @@ static void zombie_prepare_signals(void)
static inline int sig_fatal(int sig)
{
return (sig > 0) && (sig < SIGMAX) && (SIG_FATAL_MASK & (1 << sig));
return (sig > 0) && (sig < SIGMAX) && (SIG_FATAL_MASK & (1UL << sig));
}
struct task_entries *task_entries;
......
......@@ -61,7 +61,8 @@
#define CLONE_CHILD_USEPID 0x02000000
#define CLONE_VFORK 0x00004000
#define SIGMAX 32
#define SIGMAX 64
#define SIGMAX_OLD 31
#define ERESTARTSYS 512
#define ERESTARTNOINTR 513
......
......@@ -437,7 +437,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, pid_t pid,
int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_fdset)
{
struct parasite_dump_sa_args *args;
int ret, i, fd;
int ret, sig, fd;
SaEntry se = SA_ENTRY__INIT;
args = parasite_args(ctl, struct parasite_dump_sa_args);
......@@ -448,8 +448,10 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
fd = fdset_fd(cr_fdset, CR_FD_SIGACT);
for (i = 1; i < SIGMAX; i++) {
if (i == SIGSTOP || i == SIGKILL)
for (sig = 1; sig <= SIGMAX; sig++) {
int i = sig - 1;
if (sig == SIGSTOP || sig == SIGKILL)
continue;
ASSIGN_TYPED(se.sigaction, args->sas[i].rt_sa_handler);
......
......@@ -247,11 +247,13 @@ static int dump_sigact(struct parasite_dump_sa_args *da)
{
int sig, ret = 0;
for (sig = 1; sig < SIGMAX; sig++) {
for (sig = 1; sig <= SIGMAX; sig++) {
int i = sig - 1;
if (sig == SIGKILL || sig == SIGSTOP)
continue;
ret = sys_sigaction(sig, NULL, &da->sas[sig], sizeof(rt_sigset_t));
ret = sys_sigaction(sig, NULL, &da->sas[i], sizeof(rt_sigset_t));
if (ret < 0) {
pr_err("sys_sigaction failed\n");
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment