Date: Mon, 10 Jul 1995 12:55:22 +0900 From: Toshihiro Kanda <candy@fct.kgc.co.jp> To: freebsd-questions@freebsd.org Subject: How can I block a signal? Message-ID: <199507100355.MAA25071@xxx.fct.kgc.co.jp>
next in thread | raw e-mail | index | archive | help
Hi. Someone please teach me how to block a signal. My system is: >$uname -mrs >FreeBSD 2.0-RELEASE i386 The friendly manual sigprocmask(2) says "Signals are blocked if they are members of the current signal mask set." But it doesn't seem to block. I tested the following program. ---8<------8<------8<------8<------8<--- #include <signal.h> #include <stdio.h> #include <stdlib.h> void onintr(int x) { write(2, "!", 1); } int main(void) { sigset_t mask = sigmask(SIGUSR1); signal(SIGUSR1, onintr); raise(SIGUSR1); sigprocmask(SIG_BLOCK, &mask, NULL); write(2, "block\n", 6); raise(SIGUSR1); mask = sigmask(SIGUSR1); sigprocmask(SIG_UNBLOCK, &mask, NULL); write(2, "unblock\n", 8); return 0; } ---8<------8<------8<------8<------8<--- I expected it output: >!block >unblock >! But it output: >!block >!unblock Why? Is this correct and am I misunderstanding? If so, how can I block a signal? Thank you. candy@fct.kgc.co.jp (Toshihiro Kanda)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199507100355.MAA25071>