*Synopsis*: EXIT trap handlers are sometimes executed twice Due to a change requested by <User 1-5Q-9201>, <User 1-5Q-9201> is now the responsible engineer for:
CR 6907460 changed on Mar 29 2010 by <User 1-5Q-9201> === Field ============ === New Value ============= === Old Value ============= Hook 5 <email address omitted> Hook 6 <email address omitted> Keyword oss-sponsor Keyword oss-request Responsible Engineer <User 1-5Q-9201> Status 3-Accepted 1-Dispatched Targeted Release solaris_nevada ====================== =========================== =========================== *Change Request ID*: 6907460 *Synopsis*: EXIT trap handlers are sometimes executed twice Product: solaris Category: shell Subcategory: korn93 Type: Defect Subtype: Status: 3-Accepted Substatus: Priority: 2-High Introduced In Release: Introduced In Build: 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: Fixed In Build: Integrated In Build: Verified In Build: See Also: Duplicate of: Hooks: Hook1: Hook2: Hook3: Hook4: Hook5: <email address omitted> Hook6: <email address omitted> Program Management: Root Cause: 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> === *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 ======================================