aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorPaul Dagnelie <[email protected]>2021-04-15 13:34:35 -0700
committerGitHub <[email protected]>2021-04-15 13:34:35 -0700
commit414f7249dc32a579060441a644387a58e91d300a (patch)
tree4ff462d648111fd149b2f3aab032e3155121f38a /module
parentc95c5176b6a38ed5e84bcbb621e99b2d8599fb07 (diff)
Add SIGSTOP and SIGTSTP handling to issig
This change adds SIGSTOP and SIGTSTP handling to the issig function; this mirrors its behavior on Solaris. This way, long running kernel tasks can be stopped with the appropriate signals. Note that doing so with ctrl-z on the command line doesn't return control of the tty to the shell, because tty handling is done separately from stopping the process. That can be future work, if people feel that it is a necessary addition. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Issue #810 Issue #10843 Closes #11801
Diffstat (limited to 'module')
-rw-r--r--module/os/linux/spl/spl-thread.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c
index db23fb64a..834c52711 100644
--- a/module/os/linux/spl/spl-thread.c
+++ b/module/os/linux/spl/spl-thread.c
@@ -158,3 +158,54 @@ spl_kthread_create(int (*func)(void *), void *data, const char namefmt[], ...)
} while (1);
}
EXPORT_SYMBOL(spl_kthread_create);
+
+/*
+ * The "why" argument indicates the allowable side-effects of the call:
+ *
+ * FORREAL: Extract the next pending signal from p_sig into p_cursig;
+ * stop the process if a stop has been requested or if a traced signal
+ * is pending.
+ *
+ * JUSTLOOKING: Don't stop the process, just indicate whether or not
+ * a signal might be pending (FORREAL is needed to tell for sure).
+ */
+int
+issig(int why)
+{
+ ASSERT(why == FORREAL || why == JUSTLOOKING);
+
+ if (!signal_pending(current))
+ return (0);
+
+ if (why != FORREAL)
+ return (1);
+
+ struct task_struct *task = current;
+ spl_kernel_siginfo_t __info;
+ sigset_t set;
+ siginitsetinv(&set, 1ULL << (SIGSTOP - 1) | 1ULL << (SIGTSTP - 1));
+ sigorsets(&set, &task->blocked, &set);
+
+ spin_lock_irq(&task->sighand->siglock);
+ int ret;
+ if ((ret = dequeue_signal(task, &set, &__info)) != 0) {
+#ifdef HAVE_SIGNAL_STOP
+ spin_unlock_irq(&task->sighand->siglock);
+ kernel_signal_stop();
+#else
+ if (current->jobctl & JOBCTL_STOP_DEQUEUED)
+ spl_set_special_state(TASK_STOPPED);
+
+ spin_unlock_irq(&current->sighand->siglock);
+
+ schedule();
+#endif
+ return (0);
+ }
+
+ spin_unlock_irq(&task->sighand->siglock);
+
+ return (1);
+}
+
+EXPORT_SYMBOL(issig);