4.x: masking signals has no effect without signal handlers installed

Jan Pechanec jp at devnull.cz
Tue Mar 1 15:23:15 GMT 2005


	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>


More information about the freebsd-threads mailing list