Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

localtraps



Hi.

I don't seem to be able to get the localtraps option to work.

Here is my test script

<test script>

#!/bin/zsh
# sigtest

signal()
{
    setopt LOCAL_TRAPS
    trap "echo 'executing local signal() trap'" INT
    echo "--- got signal ---"
    sleep 2
}

trap signal INT


for n in 1 2 3 4 5 6
do
    echo -n "."
    sleep 1
done

echo

</test script>


<My expected result>

I expected to see "--- got signal ---" if I hit ^C, then, if I hit ^C
again within 2 seconds, before it exits signal(), I expected to see
"executing local signal() trap".  If I wait at least 2 seconds until I
see another '.' printed, then hit ^C again, I expected to see
"--- got signal ---" again.

</expected result>

On  zsh 4.2.0 (i386-unknown-freebsd5.2.1)
the trap inside signal() seems to have no effect.  Here is what I got

# ./sigtest
.^C--- got signal ---
^C--- got signal ---
^C--- got signal ---
..^C--- got signal ---
..

If I do not set localtraps, then the trap inside signal() works as
expected.

# ./sigtest

^C--- got signal ---
^Cexecuting local signal() trap
.^Cexecuting local signal() trap
.^Cexecuting local signal() trap
..^Cexecuting local signal() trap
.


On zsh 4.2.1 (i386--netbsdelf)
I got a different result with localtraps set.

# ./sigtest
.^C--- got signal ---
^C^Cexecuting local signal() trap
..^Cexecuting local signal() trap
...


As you can see, on 4.2.1 the trap inside signal() works, but the
"setopt LOCAL_TRAPS" has no effect.  It never resets the signal back
when it exits the signal() function.

If I was doing something wrong, I expected to get the same result on
both systems.  Am I overlooking something?

Regards,
Vincent

-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://www.InetAddresses.net



Messages sorted by: Reverse Date, Date, Thread, Author