hotspot/src/os/bsd/vm/jvm_bsd.cpp
changeset 34621 7676bec20997
parent 33732 2a47b89db4ec
equal deleted inserted replaced
34620:77ef20312eb2 34621:7676bec20997
   106 
   106 
   107   os::signal_raise(sig);
   107   os::signal_raise(sig);
   108   return JNI_TRUE;
   108   return JNI_TRUE;
   109 JVM_END
   109 JVM_END
   110 
   110 
   111 /*
       
   112   All the defined signal names for Bsd.
       
   113 
       
   114   NOTE that not all of these names are accepted by our Java implementation
       
   115 
       
   116   Via an existing claim by the VM, sigaction restrictions, or
       
   117   the "rules of Unix" some of these names will be rejected at runtime.
       
   118   For example the VM sets up to handle USR1, sigaction returns EINVAL for
       
   119   STOP, and Bsd simply doesn't allow catching of KILL.
       
   120 
       
   121   Here are the names currently accepted by a user of sun.misc.Signal with
       
   122   1.4.1 (ignoring potential interaction with use of chaining, etc):
       
   123 
       
   124     HUP, INT, TRAP, ABRT, IOT, BUS, USR2, PIPE, ALRM, TERM, STKFLT,
       
   125     CLD, CHLD, CONT, TSTP, TTIN, TTOU, URG, XCPU, XFSZ, VTALRM, PROF,
       
   126     WINCH, POLL, IO, PWR, SYS
       
   127 
       
   128 */
       
   129 
       
   130 struct siglabel {
       
   131   const char *name;
       
   132   int   number;
       
   133 };
       
   134 
       
   135 struct siglabel siglabels[] = {
       
   136   /* derived from /usr/include/bits/signum.h on RH7.2 */
       
   137    "HUP",       SIGHUP,         /* Hangup (POSIX).  */
       
   138   "INT",        SIGINT,         /* Interrupt (ANSI).  */
       
   139   "QUIT",       SIGQUIT,        /* Quit (POSIX).  */
       
   140   "ILL",        SIGILL,         /* Illegal instruction (ANSI).  */
       
   141   "TRAP",       SIGTRAP,        /* Trace trap (POSIX).  */
       
   142   "ABRT",       SIGABRT,        /* Abort (ANSI).  */
       
   143   "EMT",        SIGEMT,         /* EMT trap  */
       
   144   "FPE",        SIGFPE,         /* Floating-point exception (ANSI).  */
       
   145   "KILL",       SIGKILL,        /* Kill, unblockable (POSIX).  */
       
   146   "BUS",        SIGBUS,         /* BUS error (4.2 BSD).  */
       
   147   "SEGV",       SIGSEGV,        /* Segmentation violation (ANSI).  */
       
   148   "SYS",        SIGSYS,         /* Bad system call. Only on some Bsden! */
       
   149   "PIPE",       SIGPIPE,        /* Broken pipe (POSIX).  */
       
   150   "ALRM",       SIGALRM,        /* Alarm clock (POSIX).  */
       
   151   "TERM",       SIGTERM,        /* Termination (ANSI).  */
       
   152   "URG",        SIGURG,         /* Urgent condition on socket (4.2 BSD).  */
       
   153   "STOP",       SIGSTOP,        /* Stop, unblockable (POSIX).  */
       
   154   "TSTP",       SIGTSTP,        /* Keyboard stop (POSIX).  */
       
   155   "CONT",       SIGCONT,        /* Continue (POSIX).  */
       
   156   "CHLD",       SIGCHLD,        /* Child status has changed (POSIX).  */
       
   157   "TTIN",       SIGTTIN,        /* Background read from tty (POSIX).  */
       
   158   "TTOU",       SIGTTOU,        /* Background write to tty (POSIX).  */
       
   159   "IO",         SIGIO,          /* I/O now possible (4.2 BSD).  */
       
   160   "XCPU",       SIGXCPU,        /* CPU limit exceeded (4.2 BSD).  */
       
   161   "XFSZ",       SIGXFSZ,        /* File size limit exceeded (4.2 BSD).  */
       
   162   "VTALRM",     SIGVTALRM,      /* Virtual alarm clock (4.2 BSD).  */
       
   163   "PROF",       SIGPROF,        /* Profiling alarm clock (4.2 BSD).  */
       
   164   "WINCH",      SIGWINCH,       /* Window size change (4.3 BSD, Sun).  */
       
   165   "INFO",       SIGINFO,        /* Information request.  */
       
   166   "USR1",       SIGUSR1,        /* User-defined signal 1 (POSIX).  */
       
   167   "USR2",       SIGUSR2         /* User-defined signal 2 (POSIX).  */
       
   168   };
       
   169 
       
   170 JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
       
   171 
       
   172   /* find and return the named signal's number */
       
   173 
       
   174   for(uint i=0; i<ARRAY_SIZE(siglabels); i++)
       
   175     if(!strcmp(name, siglabels[i].name))
       
   176       return siglabels[i].number;
       
   177 
       
   178   return -1;
       
   179 
       
   180 JVM_END
       
   181 
       
   182 // used by os::exception_name()
       
   183 extern bool signal_name(int signo, char* buf, size_t len) {
       
   184   for(uint i = 0; i < ARRAY_SIZE(siglabels); i++) {
       
   185     if (signo == siglabels[i].number) {
       
   186       jio_snprintf(buf, len, "SIG%s", siglabels[i].name);
       
   187       return true;
       
   188     }
       
   189   }
       
   190   return false;
       
   191 }