Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
  /* Equivalent to signal( SIGUSR1, handler);
     but make signal persistent */
  struct sigaction act;
  act.sa_handler = &handler;
  act.sa_flags = 0; /* makes signal persistent by default */
  if (sigfillset( &act.sa_mask) != 0) {
    /* handle error */
  }
  if (sigaction(SIGUSR1, &act, NULL) != 0) {
    /* handle error */
  }

In fact, POSIX recommends sigaction(2) and deprecates signal(2). Unfortunately, sigaction(2) is not C99-compliant.

...

Code Block
bgColor#ccccff
  /* Equivalent to signal( SIGUSR1, handler); */
     but make signal non-persistent */
  struct sigaction act;
  act.sa_handler = &handler;
  act.sa_flags = SA_RESETHAND; /* makes signal non-persistent */
  if (sigfillset( &act.sa_mask) != 0) {
    /* handle error */
  }
  if (sigaction(SIGUSR1, &act, NULL) != 0) {
    /* handle error */
  }

In fact, POSIX recommends sigaction(2) and deprecates signal(2). Unfortunately, sigaction(2) is not C99-compliant.

...