IBM Support

How to Determine the Meaning of a Qshell Exit Status or Signal

Troubleshooting


Problem

This document explains how to determine the meaning of a Qshell exit status or signal received when an error occurs with a command or script.

Resolving The Problem

This document explains how to determine the meaning of a Qshell exit status or signal received when an error occurs with a command or script.

At some point in time, you might encounter an exit status or signal returned from the execution of a Qshell command or script. This document was written to assist you in understanding what the exit status or signal returned means.

Referencing the following URL, you can find most of the exit status meanings under 128.

https://www.ibm.com/docs/en/i/7.4?topic=commands-qsh

Exit status
  • 0 when successful.
  • 1 when unsuccessful.
  • 2 when an error occurred in a script.
  • 3 when there was an unexpected exception in a root shell.
  • 4 when there is an unexpected exception in an exception handler for a root shell.
  • 5 when there is an unexpected exception in a child shell.
  • 6 when there is an unexpected exception in an exception handler for a child shell.
  • 7 when descriptor 0 is not available.
  • 8 when descriptor 1 is not available.
  • 9 when descriptor 2 is not available.
  • 10 when there is an error opening the message catalog.
  • 11-125 when unsuccessful.
  • 126 when a command is found; however, it cannot be invoked.
  • 127 when a command cannot be found.
  • >128 when a command is ended by a signal. The value is 128 plus the signal number.

When the exit status is greater than 128, the command ended by a signal. To determine the signal number, you would take the exit status received and subtract 128. For instance, a typical exit status received is 133. If 128 is subtracted, a signal number of 5 is received. In order to determine the meaning of the signal, refer to the sys/signal.h header file on IBM i. To display the header file, run the command WRKMBRPDM FILE(QSYSINC/SYS) MBR(SIGNAL) then enter Option 5 to display the file. Scrolling down through the file, you find several #define statements that define a token with a value. In this case, the value is the numerical signal and the token is the symbolic signal name. A more descriptive definition of the signal is included to the right between the /* and */ comment indicators. If you refer to the exit status of 133, it was determined that the signal for this exit status is 5. Using the sys/signal.h header file, it can be determined that signal 5 translates to a SIGSEGV signal that equates to an invalid memory reference. This information can then be used in searches to find a matching issue or supplied to Development to help with problem determination.

Refer to the following URL for a listing of all header files for UNIX-Type functions:

https://www.ibm.com/docs/api/v1/content/ssw_ibm_i_74/apis/unix13.htm

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CbFAAU","label":"Data Access-\u003EQShell"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

629945983

Document Information

Modified date:
28 November 2024

UID

nas8N1011046