Date: Tue, 1 Mar 2005 16:23:04 +0100 (CET) From: Jan Pechanec <jp@devnull.cz> To: freebsd-threads@freebsd.org Subject: 4.x: masking signals has no effect without signal handlers installed Message-ID: <20050301155539.Q27541@axxem.hide.subzone.cz>
next in thread | raw e-mail | index | archive | help
hi all, I can see that masking signals under 4.10|11 has no effect unless I install respective signal handlers. Is it a bug, a feature or my mistake? The same program compiled under 5.3, tried with all three threads libraries, works as I would expect - masking has effect even without handlers. in this example run under 4.10|11, ^C terminates the program, compiled with: gcc -pthread -o pthread_sigmask pthread_sigmask.c if signal() call is commented out, ^C has no effect. How can I block all signals for particular thread without creating all sighandlers? Unfortunately using 5.3 is not possible for me now. regards, j. #include <sys/types.h> #include <pthread.h> #include <signal.h> #include <errno.h> #define FOR_EVER (24*3600) void sig_int_handler(int sig) { printf("SIGINT catched\n"); } int main(void) { sigset_t set; /* if (signal(SIGINT, sig_int_handler) == SIG_ERR) { perror("signal"); exit(1); } */ sigfillset(&set); if (pthread_sigmask(SIG_SETMASK, &set, NULL) != 0) { printf("pthread_sigmask() error\n"); exit(1); } // for ( ; ; ) ; sleep(FOR_EVER); printf("alive again\n"); return 0; } -- Jan Pechanec <jp (at) devnull (dot) cz>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050301155539.Q27541>