IBM Support

What is a signal and why does this matter for WebSphere Application Server

White Papers


Abstract

Signals are used for interprocess communication. For problem determination, it is often helpful to send signals to the WebSphere processes.

Content

Q: What is a signal?

A: A signal is a runtime exception from operating system native code.

Q: What are commonly used signals?

A: SIGQUIT, SIGSEGV, SIGKILL, SIGTERM, SIGILL are often discussed in WebSphere documentation and problem determination documents. Programs may be written with a signal handler to handle some of these signals. Others are only handled by the operating system.

SIGQUIT = quit, generated from terminal special char. This signal usually does not terminate the running process.

SIGSEGV = segmentation violation

SIGKILL = kill (cannot be caught or ignored).

SIGTERM = software termination signal

SIGILL = illegal instruction

Q: Why can we change the behavior of some signals, but not others?

A: Some signals are handled by user programs (e.g., SIGQUIT) and have a default behavior. Most programs include signal handler code to be invoked when the process receives this signal.

Other signals are handled by the operating system. In other words, they can't be masked or altered by the program.

Q: Where are the defined signals listed?

A: While the signals are compiled into programs, the source files are typically included in the operating system. The default location is /usr/include/signal.h. In most operating systems, this file includes /usr/include/sys/signal.h. This second file contains the actual definitions.

Q: How does Java handle signals?

A: What Java does with a particular signal is determined by the signal handler in place for java. For the common signal listed, here is what the signal frequently is indicative of:

Signal

SIGQUITgenerated by a kill -3 on the java pid. This signal does not terminate the running process.
  • This triggers the javacore for the IBM jdks.
  • It triggers a Full Thread Dump for the Sun and HP jdks
  • If heapdump or hprof is enabled, then it dumps the heap.
SIGSEGVTypically, this is caused by an error in native code. It frequently indicates a bug in the native library that generates it.
  • This triggers a javacore for the IBM jdks.
  • It generates a hs_err_pid*.log file for the Sun and HP jdks
SIGKILLTypically, this is due to a command done by a system admin or cron job.This terminates the java process without dumping any thread dumps (javacore, etc)
SIGTERMTypically, this is generated by a native library.This terminates the java process. This would typically come from a signal handler after it has handled a signal.
SIGILLTypically, this is caused by a stack overflow or jit compiler problem.
  • Examine the logs for a java.lang.StackOverflowError; fix this problem if it exists.
  • Otherwise, try the following steps:

  • 1. disable the jit compiler
    2. use the jit debug steps
    3. try skipping the method that is being jit compiled.
SIGBUSTypically, this is caused by a running program.This is sometimes caused by the older jdbc drivers that were a combination of both java and native code.

SignalDescriptionJVM Action
SIGUSR1 (SIGJVM1)User Signal 1Suspends threads doing GC
SIGUSR2User Signal 2Used by JIT
SIGFPEFloating Point Exceptnjavacore and abort
SIGSEGVSegmentation Violationjavacore and abort
SIGILLIllegal Instructionjavacore and abort
SIGABRTAbortjavacore and abort
SIGBUSBus Errorjavacore and abort
SIGEMTEmulator Errorjavacore and abort
SIGSYSBad Arg to sys calljavacore and abort
SYSXCPUCPU time limit exceededjavacore and abort
SIGXFSZFile Size limit exceededjavacore and abort
SIGQUITQuitjavacore and continue
SIGPIPEBroken PipeIgnored
SIGTERMTerminate process
SIGKILLKill processNone
SIGTRAPTrapNone
SIGALRMAlarmNone
SUGURG

SIGSTOPStopNone
SIGTSTP

SIGCONTContinueNone
SIGCHLDChildNone
SIGTTIN

SIGTTOU

SIGIO

SIGVTALRM

SIGPROF

SIGWINCH

SIGINFO

For more information on signals for AIX, see the kill command in the Commands Reference: Volume 3, i-m.

On AIX, the file
/usr/include/sys/signal.hidentifies the signals.

Here's a sample Korn shell program that illustrates use of signals. It also shows some of the limitations for users to override the signal's default behavior.

==========================================================

Work with signals:

  • Below is a Korn shell script that allows a user to see how selected signals are handled using the Unix "kill" command.
  • Also try interrupting the script using key sequences like <CTRL>-C, <CTRL>-Z and <CTRL>-\
  • The script is documented to help explain the operating system concepts associated with signals.

There is a copy of this script attached to simplify setup. However, the script still needs to be executable:

# chmod +x testsignal.ksh

==========================================================


#!/bin/ksh
# The first line ensures this script will be interpreted by the Korn shell program
#
# user functions for handling signal
onsighup ()
{
  print "\nReceived SIGHUP signal"
  print "Used to tell daemons to reread their config files."
  print Trying to override default behavior and exit
  exit
}
#
onsigterm ()
{
  print "\nReceived SIGTERM signal"
  print "Used for normal termination of a process."
  print Trying to override default behavior and exit
  exit
}
#
onsigquit ()
{
  print "\nReceived SIGQUIT signal"
  print "Used to force a program to stop."
  print Trying to override default behavior and exit
  exit
}
#
onsigint ()
{
  print "\nReceived SIGINT signal"
  print "Used to force a program to stop."
  print Trying to override default behavior and exit
  exit
}
#
onsigkill ()
{
  print "\nReceived SIGKILL signal"
  print "Used to force a program to stop."
  print Trying to override default behavior and exit
  exit
}
onsigsegv ()
{
  print "\nReceived SIGSEGV signal"
  print "Used to force a program to abort with a core file."

   print Trying to override default behavior and exit
  exit
}
#
onsigusr1 ()
{
  print "\nReceived SIGUSR1 signal"
  print "A user defined signal with no standard behavior."
  print Trying to override default behavior and exit
  exit
}
#
sethandler ()
{
  # Find the number for the signal name:
  #   This command lists the contents of 2 files, then searches
  #   for a string passed into this function.  Finally, it takes
  #   the 3rd word of the first line and assigns the result to
  #   the variable "x".
  x=$(cat /usr/include/signal.h /usr/include/sys/signal.h | grep $1 | head -1 | awk '{print $3}')
  print $1 is signal $x
  # lower case the parameter passed in and concatonate with "on"
  typeset -l y=on$1
  # set a string to be used after returning from this function
  # sample trap: trap SIGHUP onsighup
  trapstring="$y $x"
}
#
# MAIN PROGRAM STARTS HERE
#
# Uncomment next line to enable debugging
# set -x
#
# It is good to know who you are running as
print Running as user:
id
# and what this process looks like

print This process looks like:
ps -flp $$
#
# Other useful environment information that can be captured:
#  What environment variables are set?
#   env
#  What limits are set for file sizes, number of processes that can run, etc.?
#   ulimit -a
#  What are the default file permissions?
#   umask
#
print Setting up signal handlers...
#
# Setting SIGHUP by calling sethandler function
sethandler SIGHUP
trap $trapstring
#
# Setting SIGINT by calling sethandler function
sethandler SIGINT
trap $trapstring
#
# Setting SIGQUIT by calling sethandler function
sethandler SIGQUIT
trap $trapstring
#
# Setting SIGTRAP by calling sethandler function
sethandler SIGTRAP
trap $trapstring
#
# Setting SIGKILL by calling sethandler function
sethandler SIGKILL
trap $trapstring
#
# Setting SIGSEGV by calling sethandler function
sethandler SIGSEGV
trap $trapstring
#
# Setting SIGUSR1 by calling sethandler function
sethandler SIGUSR1
trap $trapstring
#
# Get summary of trap settings by running trap without parameters
print "\nListing signal handlers set:"

trap
#
# Display process ID and syntax for a kill
print "\nCurrent process is $$"
print From a different shell, send a signal to this process.
print For example: kill -3 $$
#
# Loop until receiving a signal or count reaches 100.  
# Will print a dot each 5 seconds.
let i=0
while test $i -lt 100
do
{
  print -n "."
  sleep 5
  let i=$i+1
}
done
#
print "\nExiting, counter has reached $i"
print Check /usr/include/signal.h or usr/include/sys/signal.h
print for complete list of defined signals
#

testsignal.ksh

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.0.0.0;8.5;8.0;7.0","Edition":"Advanced;Base;Express;Network Deployment;Single Server","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSEQTJ","label":"IBM HTTP Server"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Runtime","Platform":[{"code":"PF002","label":"AIX"},{"code":"","label":"HPUX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}},{"Product":{"code":"SS7JFU","label":"WebSphere Application Server - Express"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;6.1;6.0.2;6.0.1;6.0;5.1.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
07 September 2022

UID

swg27003858