134f9b3eeSRoland Mainz#
234f9b3eeSRoland Mainz# CDDL HEADER START
334f9b3eeSRoland Mainz#
434f9b3eeSRoland Mainz# The contents of this file are subject to the terms of the
534f9b3eeSRoland Mainz# Common Development and Distribution License (the "License").
634f9b3eeSRoland Mainz# You may not use this file except in compliance with the License.
734f9b3eeSRoland Mainz#
834f9b3eeSRoland Mainz# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
934f9b3eeSRoland Mainz# or http://www.opensolaris.org/os/licensing.
1034f9b3eeSRoland Mainz# See the License for the specific language governing permissions
1134f9b3eeSRoland Mainz# and limitations under the License.
1234f9b3eeSRoland Mainz#
1334f9b3eeSRoland Mainz# When distributing Covered Code, include this CDDL HEADER in each
1434f9b3eeSRoland Mainz# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1534f9b3eeSRoland Mainz# If applicable, add the following below this CDDL HEADER, with the
1634f9b3eeSRoland Mainz# fields enclosed by brackets "[]" replaced with your own identifying
1734f9b3eeSRoland Mainz# information: Portions Copyright [yyyy] [name of copyright owner]
1834f9b3eeSRoland Mainz#
1934f9b3eeSRoland Mainz# CDDL HEADER END
2034f9b3eeSRoland Mainz#
2134f9b3eeSRoland Mainz
2234f9b3eeSRoland Mainz#
233e14f97fSRoger A. Faulkner# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2434f9b3eeSRoland Mainz#
2534f9b3eeSRoland Mainz
2634f9b3eeSRoland Mainz#
2734f9b3eeSRoland Mainz# This test checks whether ksh93 supports traps for the SIGTHAW
2834f9b3eeSRoland Mainz# signal.
2934f9b3eeSRoland Mainz#
3034f9b3eeSRoland Mainz# This was reported as CR #6778077 ("*ksh93* does not understand "THAW"
3134f9b3eeSRoland Mainz# as a signal for use with trap"):
3234f9b3eeSRoland Mainz# -- snip --
3334f9b3eeSRoland Mainz# While ksh93 understand THAW in the list of signals for kill it does
3434f9b3eeSRoland Mainz# not understand it for "trap'
35*b30d1939SAndy Fiddaman#
3634f9b3eeSRoland Mainz# : pod5.eu TS 6 $; kill -l | egrep '(THAW|FREEZE)'
3734f9b3eeSRoland Mainz# FREEZE
3834f9b3eeSRoland Mainz# THAW
3934f9b3eeSRoland Mainz# : pod5.eu TS 7 $; trap "echo THAW" THAW
4034f9b3eeSRoland Mainz# ksh93: trap: THAW: bad trap
4134f9b3eeSRoland Mainz# : pod5.eu TS 8 $;
42*b30d1939SAndy Fiddaman#
4334f9b3eeSRoland Mainz# Using the signal number (35) works around this.
4434f9b3eeSRoland Mainz# -- snip --
4534f9b3eeSRoland Mainz#
4634f9b3eeSRoland Mainz
4734f9b3eeSRoland Mainz# test setup
4834f9b3eeSRoland Mainzfunction err_exit
4934f9b3eeSRoland Mainz{
5034f9b3eeSRoland Mainz	print -u2 -n "\t"
5134f9b3eeSRoland Mainz	print -u2 -r ${Command}[$1]: "${@:2}"
523e14f97fSRoger A. Faulkner	(( Errors < 127 && Errors++ ))
5334f9b3eeSRoland Mainz}
5434f9b3eeSRoland Mainzalias err_exit='err_exit $LINENO'
5534f9b3eeSRoland Mainz
5634f9b3eeSRoland Mainzset -o nounset
5734f9b3eeSRoland MainzCommand=${0##*/}
5834f9b3eeSRoland Mainzinteger Errors=0
5934f9b3eeSRoland Mainz
6034f9b3eeSRoland Mainz
6134f9b3eeSRoland Mainz## test one: Check whether the shell supports SIGTHAW as trap
6234f9b3eeSRoland Mainz${SHELL} -o errexit -c 'trap "true" SIGTHAW ; true' || err_exit "SIGTHAW not supported."
6334f9b3eeSRoland Mainz${SHELL} -o errexit -c 'trap "true" THAW ; true'    || err_exit "THAW not supported."
6434f9b3eeSRoland Mainz${SHELL} -o errexit -c 'trap "true" 35 ; true'      || err_exit "signal 35 not supported."
6534f9b3eeSRoland Mainz
6634f9b3eeSRoland Mainz
6734f9b3eeSRoland Mainz## test two: Check whether the shell supports SIGFREEZE as trap
6834f9b3eeSRoland Mainz## (we check this since it is SIGTHAW's counterpart)
6934f9b3eeSRoland Mainz${SHELL} -o errexit -c 'trap "true" SIGFREEZE ; true' || err_exit "SIGFREEZE not supported."
7034f9b3eeSRoland Mainz${SHELL} -o errexit -c 'trap "true" FREEZE ; true'    || err_exit "FREEZE not supported."
7134f9b3eeSRoland Mainz${SHELL} -o errexit -c 'trap "true" 34 ; true'        || err_exit "signal 34 not supported."
7234f9b3eeSRoland Mainz
7334f9b3eeSRoland Mainz
7434f9b3eeSRoland Mainz## test three: Check all other signals listed by "kill -l"
7534f9b3eeSRoland Mainzkill -l | while read i ; do
7634f9b3eeSRoland Mainz	str="$( ${SHELL} -c "trap true $i ; print 'ok'" 2>&1 )" || err_exit "shell returned code $? for trap $i"
7734f9b3eeSRoland Mainz	[[ "${str}" == "ok" ]] || err_exit "expected 'ok', got $str"
7834f9b3eeSRoland Mainzdone
7934f9b3eeSRoland Mainz
8034f9b3eeSRoland Mainz
8134f9b3eeSRoland Mainz# tests done
8234f9b3eeSRoland Mainzexit $((Errors))
83