*Synopsis*: EXIT trap handlers are sometimes executed twice

     
*Change Request ID*: 6907460

*Synopsis*: EXIT trap handlers are sometimes executed twice

  Product: solaris
  Category: shell
  Subcategory: korn93
  Type: Defect
  Subtype: 
  Status: 1-Dispatched
  Substatus: 
  Priority: 2-High
  Introduced In Release: 
  Introduced In Build: 
  Responsible Engineer: 
  Keywords: 

=== *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* ========================================================

=== *Workaround* =============================================================

=== *Additional Details* =====================================================
        Targeted Release: 
        Commit To Fix In Build: 
        Fixed In Build: 
        Integrated In Build: 
        Verified In Build: 
  See Also: 
  Duplicate of: 
  Hooks:
        Hook1: 
        Hook2: 
        Hook3: 
        Hook4: 
        Hook5: 
        Hook6: 
  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


=== *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 ======================================

Reply via email to