Print this page
8548 want memset_s(3C)
Reviewed by: Robert Mustacchi <rm@joyent.com>


  78 
  79         /* set SIGABRT signal handler to SIG_DFL w/o grabbing any locks */
  80         (void) memset(&act, 0, sizeof (act));
  81         act.sa_sigaction = SIG_DFL;
  82         (void) __sigaction(SIGABRT, &act, NULL);
  83 
  84         /* delete SIGABRT from the signal mask */
  85         (void) sigemptyset(&sigmask);
  86         (void) sigaddset(&sigmask, SIGABRT);
  87         (void) __lwp_sigmask(SIG_UNBLOCK, &sigmask);
  88 
  89         (void) _lwp_kill(lwpid, SIGABRT);       /* never returns */
  90         (void) kill(getpid(), SIGABRT); /* if it does, try harder */
  91         _exit(127);
  92 }
  93 
  94 /*
  95  * Write a panic message w/o grabbing any locks other than assert_lock.
  96  * We have no idea what locks are held at this point.
  97  */
  98 static void
  99 common_panic(const char *head, const char *why)
 100 {
 101         char msg[400];  /* no panic() message in the library is this long */
 102         ulwp_t *self;
 103         size_t len1, len2;
 104 
 105         if ((self = __curthread()) != NULL)
 106                 enter_critical(self);
 107         (void) _lwp_mutex_lock(&assert_lock);
 108 
 109         (void) memset(msg, 0, sizeof (msg));
 110         (void) strcpy(msg, head);
 111         len1 = strlen(msg);
 112         len2 = strlen(why);
 113         if (len1 + len2 >= sizeof (msg))
 114                 len2 = sizeof (msg) - len1 - 1;
 115         (void) strncat(msg, why, len2);
 116         len1 = strlen(msg);
 117         if (msg[len1 - 1] != '\n')
 118                 msg[len1++] = '\n';




  78 
  79         /* set SIGABRT signal handler to SIG_DFL w/o grabbing any locks */
  80         (void) memset(&act, 0, sizeof (act));
  81         act.sa_sigaction = SIG_DFL;
  82         (void) __sigaction(SIGABRT, &act, NULL);
  83 
  84         /* delete SIGABRT from the signal mask */
  85         (void) sigemptyset(&sigmask);
  86         (void) sigaddset(&sigmask, SIGABRT);
  87         (void) __lwp_sigmask(SIG_UNBLOCK, &sigmask);
  88 
  89         (void) _lwp_kill(lwpid, SIGABRT);       /* never returns */
  90         (void) kill(getpid(), SIGABRT); /* if it does, try harder */
  91         _exit(127);
  92 }
  93 
  94 /*
  95  * Write a panic message w/o grabbing any locks other than assert_lock.
  96  * We have no idea what locks are held at this point.
  97  */
  98 void
  99 common_panic(const char *head, const char *why)
 100 {
 101         char msg[400];  /* no panic() message in the library is this long */
 102         ulwp_t *self;
 103         size_t len1, len2;
 104 
 105         if ((self = __curthread()) != NULL)
 106                 enter_critical(self);
 107         (void) _lwp_mutex_lock(&assert_lock);
 108 
 109         (void) memset(msg, 0, sizeof (msg));
 110         (void) strcpy(msg, head);
 111         len1 = strlen(msg);
 112         len2 = strlen(why);
 113         if (len1 + len2 >= sizeof (msg))
 114                 len2 = sizeof (msg) - len1 - 1;
 115         (void) strncat(msg, why, len2);
 116         len1 = strlen(msg);
 117         if (msg[len1 - 1] != '\n')
 118                 msg[len1++] = '\n';