help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

exit status of 128 + signal number when a process kills itself via a sig


From: Harmon S. Nine
Subject: exit status of 128 + signal number when a process kills itself via a signal
Date: Fri, 3 Nov 2000 09:42:22 -0500 (EST)

Hello.  Please forgive if this is not the right mailing list, but I wasn't
sure where else to turn except to the GNU folks.  I have a question
concerning the exit status of a process when it kills itself by sending
itself a signal, e.g. via one of:

kill( getpid(), 9 );
raise(9);


The following is only to show that I have a grasp of exit status:
-----------------------------------------------------------------------
The exit status for process can be access by the process's parent via a
"wait" system call and an integer, i.e. the parent does:

int status;
wait(&status);

The exit status is put in the integer variable "status", and looks like:

-------------------------------------
|    0   |    0   |    E   |    S   |
-------------------------------------

If the process was terminated by a signal, E = 0, and S is set to the
number of the signal that terminated the process.  If the process was
terminated by an "exit" system call, S = 0, and E is the argument that was
provided to the "exit" system call by the process.
------------------------------------------------------------------------


OK, here's my question:

Normally, when a process is sent a signal 9, i.e. from another process,
its exit status conforms to the description above, i.e. it is:

-------------------------------------
|    0   |    0   |    0   |    9   |
-------------------------------------

However, when a process sends *itself* this same signal (9), using one of

kill( getpid(), 9 );
raise(9);

and consequently kills itself, its exit status is:

-------------------------------------
|    0   |    0   |  128+9 |    0   |
-------------------------------------

This happens as well when the process terminates itself by sending itself
other signals.  That is, if the process terminates itself with

raise(15);

its exit status is:

-------------------------------------
|    0   |    0   | 128+15 |    0   |
-------------------------------------

instead of:

-------------------------------------
|    0   |    0   |    0   |   15   |
-------------------------------------


Is this a standard/convention?  If so, is there a place where I can find
more information about it?  I've looked on the web, but was only able to
find a small blurb on how exit statuses greater than 128 are reserved.


TIA


-- Harmon S. Nine




reply via email to

[Prev in Thread] Current Thread [Next in Thread]