File: system-status.awk

package info (click to toggle)
original-awk 2018-08-27-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 7,172 kB
  • sloc: ansic: 5,074; yacc: 407; awk: 65; makefile: 63; sh: 23
file content (19 lines) | stat: -rw-r--r-- 575 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Unmodified nawk prints the 16 bit exit status divided by 256, but
# does so using floating point arithmetic, yielding strange results.
#
# The fix is to use the various macros defined for wait(2) and to
# use the signal number + 256 for death by signal, or signal number + 512
# for death by signal with core dump.

BEGIN {
	status = system("exit 42")
	print "normal status", status

	status = system("kill -HUP $$")
	print "death by signal status", status

	status = system("kill -ABRT $$")
	print "death by signal with core dump status", status

	system("rm -f core*")
}