[CRIU] [PATCH 1/2] signal: fix logig about SIGMAX

Andrey Vagin avagin at openvz.org
Mon Dec 3 07:05:31 EST 2012


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.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-restore.c       | 6 +++---
 parasite-syscall.c | 8 +++++---
 pie/parasite.c     | 6 ++++--
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 48577a7..52657bb 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -531,7 +531,7 @@ 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;
 
@@ -649,7 +649,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);
 }
 
@@ -684,7 +684,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;
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 8c889da..2086cf1 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -457,7 +457,7 @@ int parasite_dump_signal_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_fd
 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);
@@ -468,8 +468,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);
diff --git a/pie/parasite.c b/pie/parasite.c
index e0d7118..422d13d 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -299,11 +299,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;
-- 
1.7.11.7



More information about the CRIU mailing list