hotspot/src/os/bsd/vm/jvm_bsd.cpp
author coleenp
Thu, 11 Dec 2014 21:34:43 -0500
changeset 28163 322d55d167be
parent 10565 dc90c239f4ec
child 33732 2a47b89db4ec
permissions -rw-r--r--
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint Summary: Ensure consistent safepoint checking in Mutex/Monitor locking methods. Reviewed-by: dholmes, dcubed, coleenp Contributed-by: max.ockner@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     1
/*
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     2
 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     4
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     8
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    13
 * accompanied this code).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    14
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    18
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    21
 * questions.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    22
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    23
 */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    24
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    25
#include "precompiled.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    26
#include "prims/jvm.h"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    27
#include "runtime/interfaceSupport.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    28
#include "runtime/osThread.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    30
#include <signal.h>
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    31
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    32
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    33
// sun.misc.Signal ///////////////////////////////////////////////////////////
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    34
// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    35
/*
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    36
 * This function is included primarily as a debugging aid. If Java is
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    37
 * running in a console window, then pressing <CTRL-\\> will cause
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    38
 * the current state of all active threads and monitors to be written
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    39
 * to the console window.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    40
 */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    41
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    42
JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    43
  // Copied from classic vm
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    44
  // signals_md.c       1.4 98/08/23
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    45
  void* newHandler = handler == (void *)2
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    46
                   ? os::user_handler()
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    47
                   : handler;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    48
  switch (sig) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    49
    /* The following are already used by the VM. */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    50
    case INTERRUPT_SIGNAL:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    51
    case SIGFPE:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    52
    case SIGILL:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    53
    case SIGSEGV:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    54
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    55
    /* The following signal is used by the VM to dump thread stacks unless
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    56
       ReduceSignalUsage is set, in which case the user is allowed to set
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    57
       his own _native_ handler for this signal; thus, in either case,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    58
       we do not allow JVM_RegisterSignal to change the handler. */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    59
    case BREAK_SIGNAL:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    60
      return (void *)-1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    61
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    62
    /* The following signals are used for Shutdown Hooks support. However, if
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    63
       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    64
       System.exit(), Java is not allowed to use these signals, and the the
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    65
       user is allowed to set his own _native_ handler for these signals and
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    66
       invoke System.exit() as needed. Terminator.setup() is avoiding
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    67
       registration of these signals when -Xrs is present.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    68
       - If the HUP signal is ignored (from the nohup) command, then Java
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    69
         is not allowed to use this signal.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    70
     */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    71
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    72
    case SHUTDOWN1_SIGNAL:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    73
    case SHUTDOWN2_SIGNAL:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    74
    case SHUTDOWN3_SIGNAL:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    75
      if (ReduceSignalUsage) return (void*)-1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    76
      if (os::Bsd::is_sig_ignored(sig)) return (void*)1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    77
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    78
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    79
  void* oldHandler = os::signal(sig, newHandler);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    80
  if (oldHandler == os::user_handler()) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    81
      return (void *)2;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    82
  } else {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    83
      return oldHandler;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    84
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    85
JVM_END
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    86
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    87
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    88
JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    89
  if (ReduceSignalUsage) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    90
    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    91
    // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    92
    // no handler for them is actually registered in JVM or via
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    93
    // JVM_RegisterSignal.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    94
    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    95
        sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    96
      return JNI_FALSE;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    97
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    98
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    99
  else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   100
            sig == SHUTDOWN3_SIGNAL) && os::Bsd::is_sig_ignored(sig)) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   101
    // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   102
    // is ignored, since no handler for them is actually registered in JVM
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   103
    // or via JVM_RegisterSignal.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   104
    // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   105
    return JNI_FALSE;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   106
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   107
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   108
  os::signal_raise(sig);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   109
  return JNI_TRUE;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   110
JVM_END
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   111
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   112
/*
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   113
  All the defined signal names for Bsd.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   114
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   115
  NOTE that not all of these names are accepted by our Java implementation
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   116
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   117
  Via an existing claim by the VM, sigaction restrictions, or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   118
  the "rules of Unix" some of these names will be rejected at runtime.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   119
  For example the VM sets up to handle USR1, sigaction returns EINVAL for
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   120
  STOP, and Bsd simply doesn't allow catching of KILL.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   121
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   122
  Here are the names currently accepted by a user of sun.misc.Signal with
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   123
  1.4.1 (ignoring potential interaction with use of chaining, etc):
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   124
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   125
    HUP, INT, TRAP, ABRT, IOT, BUS, USR2, PIPE, ALRM, TERM, STKFLT,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   126
    CLD, CHLD, CONT, TSTP, TTIN, TTOU, URG, XCPU, XFSZ, VTALRM, PROF,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   127
    WINCH, POLL, IO, PWR, SYS
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   128
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   129
*/
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   130
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   131
struct siglabel {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   132
  const char *name;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   133
  int   number;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   134
};
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   135
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   136
struct siglabel siglabels[] = {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   137
  /* derived from /usr/include/bits/signum.h on RH7.2 */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   138
   "HUP",       SIGHUP,         /* Hangup (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   139
  "INT",        SIGINT,         /* Interrupt (ANSI).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   140
  "QUIT",       SIGQUIT,        /* Quit (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   141
  "ILL",        SIGILL,         /* Illegal instruction (ANSI).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   142
  "TRAP",       SIGTRAP,        /* Trace trap (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   143
  "ABRT",       SIGABRT,        /* Abort (ANSI).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   144
  "EMT",        SIGEMT,         /* EMT trap  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   145
  "FPE",        SIGFPE,         /* Floating-point exception (ANSI).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   146
  "KILL",       SIGKILL,        /* Kill, unblockable (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   147
  "BUS",        SIGBUS,         /* BUS error (4.2 BSD).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   148
  "SEGV",       SIGSEGV,        /* Segmentation violation (ANSI).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   149
  "SYS",        SIGSYS,         /* Bad system call. Only on some Bsden! */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   150
  "PIPE",       SIGPIPE,        /* Broken pipe (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   151
  "ALRM",       SIGALRM,        /* Alarm clock (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   152
  "TERM",       SIGTERM,        /* Termination (ANSI).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   153
  "URG",        SIGURG,         /* Urgent condition on socket (4.2 BSD).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   154
  "STOP",       SIGSTOP,        /* Stop, unblockable (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   155
  "TSTP",       SIGTSTP,        /* Keyboard stop (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   156
  "CONT",       SIGCONT,        /* Continue (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   157
  "CHLD",       SIGCHLD,        /* Child status has changed (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   158
  "TTIN",       SIGTTIN,        /* Background read from tty (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   159
  "TTOU",       SIGTTOU,        /* Background write to tty (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   160
  "IO",         SIGIO,          /* I/O now possible (4.2 BSD).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   161
  "XCPU",       SIGXCPU,        /* CPU limit exceeded (4.2 BSD).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   162
  "XFSZ",       SIGXFSZ,        /* File size limit exceeded (4.2 BSD).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   163
  "VTALRM",     SIGVTALRM,      /* Virtual alarm clock (4.2 BSD).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   164
  "PROF",       SIGPROF,        /* Profiling alarm clock (4.2 BSD).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   165
  "WINCH",      SIGWINCH,       /* Window size change (4.3 BSD, Sun).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   166
  "INFO",       SIGINFO,        /* Information request.  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   167
  "USR1",       SIGUSR1,        /* User-defined signal 1 (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   168
  "USR2",       SIGUSR2         /* User-defined signal 2 (POSIX).  */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   169
  };
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   170
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   171
JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   172
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   173
  /* find and return the named signal's number */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   174
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   175
  for(uint i=0; i<ARRAY_SIZE(siglabels); i++)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   176
    if(!strcmp(name, siglabels[i].name))
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   177
      return siglabels[i].number;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   178
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   179
  return -1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   180
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   181
JVM_END
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   182
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   183
// used by os::exception_name()
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   184
extern bool signal_name(int signo, char* buf, size_t len) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   185
  for(uint i = 0; i < ARRAY_SIZE(siglabels); i++) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   186
    if (signo == siglabels[i].number) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   187
      jio_snprintf(buf, len, "SIG%s", siglabels[i].name);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   188
      return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   189
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   190
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   191
  return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   192
}