1# 2# CDDL HEADER START 3# 4# The contents of this file are subject to the terms of the 5# Common Development and Distribution License (the "License"). 6# You may not use this file except in compliance with the License. 7# 8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9# or http://www.opensolaris.org/os/licensing. 10# See the License for the specific language governing permissions 11# and limitations under the License. 12# 13# When distributing Covered Code, include this CDDL HEADER in each 14# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15# If applicable, add the following below this CDDL HEADER, with the 16# fields enclosed by brackets "[]" replaced with your own identifying 17# information: Portions Copyright [yyyy] [name of copyright owner] 18# 19# CDDL HEADER END 20# 21 22# 23# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 24# 25 26# 27# This test checks whether ksh93 supports traps for the SIGTHAW 28# signal. 29# 30# This was reported as CR #6778077 ("*ksh93* does not understand "THAW" 31# as a signal for use with trap"): 32# -- snip -- 33# While ksh93 understand THAW in the list of signals for kill it does 34# not understand it for "trap' 35# 36# : pod5.eu TS 6 $; kill -l | egrep '(THAW|FREEZE)' 37# FREEZE 38# THAW 39# : pod5.eu TS 7 $; trap "echo THAW" THAW 40# ksh93: trap: THAW: bad trap 41# : pod5.eu TS 8 $; 42# 43# Using the signal number (35) works around this. 44# -- snip -- 45# 46 47# test setup 48function err_exit 49{ 50 print -u2 -n "\t" 51 print -u2 -r ${Command}[$1]: "${@:2}" 52 (( Errors < 127 && Errors++ )) 53} 54alias err_exit='err_exit $LINENO' 55 56set -o nounset 57Command=${0##*/} 58integer Errors=0 59 60 61## test one: Check whether the shell supports SIGTHAW as trap 62${SHELL} -o errexit -c 'trap "true" SIGTHAW ; true' || err_exit "SIGTHAW not supported." 63${SHELL} -o errexit -c 'trap "true" THAW ; true' || err_exit "THAW not supported." 64${SHELL} -o errexit -c 'trap "true" 35 ; true' || err_exit "signal 35 not supported." 65 66 67## test two: Check whether the shell supports SIGFREEZE as trap 68## (we check this since it is SIGTHAW's counterpart) 69${SHELL} -o errexit -c 'trap "true" SIGFREEZE ; true' || err_exit "SIGFREEZE not supported." 70${SHELL} -o errexit -c 'trap "true" FREEZE ; true' || err_exit "FREEZE not supported." 71${SHELL} -o errexit -c 'trap "true" 34 ; true' || err_exit "signal 34 not supported." 72 73 74## test three: Check all other signals listed by "kill -l" 75kill -l | while read i ; do 76 str="$( ${SHELL} -c "trap true $i ; print 'ok'" 2>&1 )" || err_exit "shell returned code $? for trap $i" 77 [[ "${str}" == "ok" ]] || err_exit "expected 'ok', got $str" 78done 79 80 81# tests done 82exit $((Errors)) 83