On Tue, Jun 11, 2024 at 01:26:50PM +0530, Dev Jain wrote:
+ * A signal is said to be delivered, when the program takes action on theI'm not sure that's what my understanding of a blocked signal is, I
+ * signal: such action may involve termination of the process, ignoring the
+ * signal, terminating with core dump, stopping the process, or continuing the
+ * process if it was currently stopped. A signal is said to be blocked when the
+ * program refuses to take any of the above actions; note that, this is not the
+ * same as ignoring the signal. At a later time, the program may unblock the
+ * signal and then it will have to take one of the five actions
+ * described above.
would interpret "blocked" as a signal being masked (this usage can be
seen in for example sigaction(2)). I'd also interpret delivery of the
signal as happening when the signal handler is invoked rather than
something that the handler has control over (the comment later on says
that so I think it's just an issue here). Perhaps I'm confused about
terminology though, this is just usage I've picked up and ICBW.
+ * For standard signals (also see real-time signals in the man page), multipleSee also SA_NODEFER.
+ * blocked instances of the same signal are not queued; such a signal will
+ * be delivered just once.
+ /* SEGV has been blocked in sa_mask, but ucontext is invariant */We're not manipulating the masks outside of main() so it's a bit unclear
+ ret = sigismember(&(((ucontext_t *)uc)->uc_sigmask), SIGSEGV);
+ ksft_test_result(ret == 0, "SEGV not blocked in ucontext\n");
+
+ /* USR1 has been blocked, but ucontext is invariant */
+ ret = sigismember(&(((ucontext_t *)uc)->uc_sigmask), SIGUSR1);
+ ksft_test_result(ret == 0, "USR1 not blocked in ucontext\n");
what the mention of ucontext being invariant is all about here?
+ /* Mangled ucontext implies USR2 is blocked for current thread */But we just raised SIGUSR1 rather than SIGUSR2? If nothing else this
+ if (raise(SIGUSR2))
+ ksft_exit_fail_perror("raise");
+
+ ksft_print_msg("USR2 bypassed successfully\n");
+
+ act.sa_sigaction = &handler_verify_ucontext;
+ if (sigaction(SIGUSR1, &act, NULL))
+ ksft_exit_fail_perror("Cannot install handler");
+
+ if (raise(SIGUSR1))
+ ksft_exit_fail_perror("raise");
+
+ ksft_print_msg("USR2 still blocked on return from handler\n");
bit is a little unclear.