[PATCH] cgroup: freezer: Don't wake up process really blocked on signal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Process who's waiting for specific sigset shouldn't be woke up
neither it is moved between different cgroups nor the cgroup it
belongs to changes the frozen state. We'd better keep it as is
and let it wait for the desired signals coming.

Following test case is one scenario which will get "Interrupted
system call" error if we wake it up in cgroup_freeze_task().

int main(int argc, char *argv[])
{
        sigset_t waitset;
        int signo;

        sigemptyset(&waitset);
        sigaddset(&waitset, SIGINT);
        sigaddset(&waitset, SIGUSR1);

        pthread_sigmask(SIG_BLOCK, &waitset, NULL);

        for (;;) {
                signo = sigwaitinfo(&waitset, NULL);
                if (signo < 0)
                        err(1, "sigwaitinfo() failed");

                if (signo == SIGUSR1)
                        printf("Receive SIGUSR1\n");
                else
                        break;
        }

        return 0;
}

Signed-off-by: Honglei Wang <honglei.wang@xxxxxxxxxx>
---
 kernel/cgroup/freezer.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/freezer.c b/kernel/cgroup/freezer.c
index 8cf010680678..08f6abacaa75 100644
--- a/kernel/cgroup/freezer.c
+++ b/kernel/cgroup/freezer.c
@@ -162,10 +162,14 @@ static void cgroup_freeze_task(struct task_struct *task, bool freeze)
 
 	if (freeze) {
 		task->jobctl |= JOBCTL_TRAP_FREEZE;
-		signal_wake_up(task, false);
+
+		if (sigisemptyset(&task->real_blocked))
+			signal_wake_up(task, false);
 	} else {
 		task->jobctl &= ~JOBCTL_TRAP_FREEZE;
-		wake_up_process(task);
+
+		if (sigisemptyset(&task->real_blocked))
+			wake_up_process(task);
 	}
 
 	unlock_task_sighand(task, &flags);
-- 
2.17.0




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux