From owner-freebsd-questions Sun Jul 9 21:15:35 1995 Return-Path: questions-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id VAA24895 for questions-outgoing; Sun, 9 Jul 1995 21:15:35 -0700 Received: from mail0.iij.ad.jp (root@mail0.iij.ad.jp [192.244.176.61]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id VAA24887 for ; Sun, 9 Jul 1995 21:15:23 -0700 Received: from uucp0.iij.ad.jp (uucp0.iij.ad.jp [192.244.176.51]) by mail0.iij.ad.jp (8.6.12+2.4W/3.3W9-MAIL) with ESMTP id NAA29270 for ; Mon, 10 Jul 1995 13:15:18 +0900 Received: (from uucp@localhost) by uucp0.iij.ad.jp (8.6.12+2.4W/3.3W9-UUCP) with UUCP id NAA28300 for freebsd-questions@freebsd.org; Mon, 10 Jul 1995 13:15:19 +0900 Received: from xxx.fct.kgc.co.jp by fender.fct.kgc.co.jp (8.6.12+2.4W/3.3W8:95063017) id MAA26854; Mon, 10 Jul 1995 12:55:24 +0900 Received: from localhost by xxx.fct.kgc.co.jp (8.6.12+2.4W/3.3W8:95062916) id MAA25071; Mon, 10 Jul 1995 12:55:23 +0900 Message-Id: <199507100355.MAA25071@xxx.fct.kgc.co.jp> To: freebsd-questions@freebsd.org Subject: How can I block a signal? Date: Mon, 10 Jul 1995 12:55:22 +0900 From: Toshihiro Kanda Sender: questions-owner@freebsd.org Precedence: bulk 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 #include #include 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)