xref: /illumos-gate/usr/src/test/util-tests/tests/awk/bugs-fixed/system-status.awk (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1# Unmodified nawk prints the 16 bit exit status divided by 256, but
2# does so using floating point arithmetic, yielding strange results.
3#
4# The fix is to use the various macros defined for wait(2) and to
5# use the signal number + 256 for death by signal, or signal number + 512
6# for death by signal with core dump.
7
8BEGIN {
9	status = system("exit 42")
10	print "normal status", status
11
12	status = system("kill -KILL $$")
13	print "death by signal status", status
14
15	status = system("cd $WORKDIR && kill -ABRT $$")
16	print "death by signal with core dump status", status
17
18	system("rm -f core*")
19}
20