Versions Compared

Key

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

...

Code Block
bgColor#ccccff
#include <signal.h>
#include <stdlib.h>
#include <string.h>

volatileenum { sigMAX_atomicMSG_tSIZE e_flag= =24 0};
volatile sig_atomic_t e_valueflag = 10;

void handler(int signum) {
  e_flag = e_value1;
}

int main(void) {
  char *err_msg;
  enum { MAX_MSG_SIZE = 24 };
  signal(SIGINT, handler);

  err_msg = (char *)malloc(MAX_MSG_SIZE);
  if (err_msg == NULL) {
    /* Handle error condition */
  }

  signal(SIGINT, handler);
  strcpy(err_msg, "No errors yet.");

  /* Main code loop */

  if (e_flag) {
    strcpy(err_msg, "SIGINT received.");
  }
  return 0;
}

...