*Synopsis*: EXIT trap handlers are sometimes executed twice
CR 6907460 changed on Mar 30 2010 by <User 1-9HOB9N>
=== Field ============ === New Value ============= === Old Value =============
See Also 6939349
====================== =========================== ===========================
*Change Request ID*: 6907460
*Synopsis*: EXIT trap handlers are sometimes executed twice
Product: solaris
Category: shell
Subcategory: korn93
Type: Defect
Subtype: Functionality
Status: 7-Fix in Progress
Substatus:
Priority: 2-High
Introduced In Release: solaris_nevada
Introduced In Build: snv_128
Responsible Engineer: <User 1-5Q-9201>
Keywords: oss-request, oss-sponsor
=== *Description* ============================================================
During SST testing of snv_128(RE) we found out that ksh93 executes EXIT trap
handlers twice under some circumstances.
Here is a test script:
---
#!/bin/ksh93 -x
function A
{
set -x
trap "print TRAP A >>log" EXIT
print >&2
}
function B
{
set -x
trap "print TRAP B >>log" EXIT
A
}
rm -f log
x=$(B)
---
It produces the following output on snv_128:
---
+ rm -f log
+ B
+ trap 'print TRAP B >>log' EXIT
+ A
+ trap 'print TRAP A >>log' EXIT
+ print
+ + print TRAP A
1>& 2
+ 1>> log
+ print TRAP B
+ 1>> log
+ print TRAP A
+ 1>> log
+ print TRAP B
+ 1>> log
+ x=''
---
The log file then contains:
TRAP A
TRAP B
TRAP A
TRAP B
However, the expected log would be:
TRAP A
TRAP B
When the "x=$(B)" line is changed to "B", the log is correct:
TRAP A
TRAP B
*** (#1 of 1): 2009-12-04 16:28:18 GMT+00:00 <User 1-71ST03>
=== *Public Comments* ========================================================
Roland Mainz has a fix in progress, but needs a sponsor.
*** (#1 of 1): 2009-12-04 23:17:14 GMT+00:00 <User 1-5Q-1267>
=== *Workaround* =============================================================
Workaround provided by Roland Mainz:
1. You may use the foo=${ cmd ; } style command substitution which runs
"cmd" in the current subshell level, e.g. replace x=$(B) with x=${ B ; }
OR
2. Use the following statement as replacement for x=$(B), too:
x=$( printf "%s\n" "${ B ; }" )
*** (#1 of 1): 2009-12-04 23:17:14 GMT+00:00 <User 1-5Q-1267>
=== *Additional Details* =====================================================
Targeted Release: solaris_nevada
Commit To Fix In Build: snv_137
Fixed In Build:
Integrated In Build:
Verified In Build:
See Also: 6939349
Duplicate of:
Hooks:
Hook1:
Hook2:
Hook3:
Hook4:
Hook5: <email address omitted>
Hook6: <email address omitted>
Program Management:
Root Cause: Another Bug Fix
Fix Affects Documentation: No
Fix Affects Localization: No
=== *History* ================================================================
Date Submitted: 2009-12-04 16:28:18 GMT+00:00
Submitted By: <User 1-71ST03>
Status Changed Date Updated Updated By
3-Accepted 2010-03-29 02:37:21 GMT+00:00 <User 1-5Q-9201>
7-Fix in Progress 2010-03-29 03:14:26 GMT+00:00 <User 1-5Q-9201>
=== *Service Request* ========================================================
Impact: Significant
Functionality: Primary
Severity: 2
Product Name: solaris
Product Release: solaris_nevada
Product Build: snv_128
Operating System: snv_128
Hardware: generic
Submitted Date: 2009-12-04 16:28:18 GMT+00:00
=== *Multiple Release (MR) Cluster* - 0 ======================================