Hello,

with ksh93t+ the trap actions in the following script leads to a
termination of the script:

----8<----

read_timeout () {
    trap 'printf "timed out\n"; trap - TERM; return' TERM
    ( sleep $1; kill -TERM $$ ) >/dev/null 2>&1 &
    timer_pid=$!
    read $2
    kill $timer_pid 2>/dev/null
}

read_timeout 5 value
printf "read \"%s\"\n" "${value:-default}"

---->8----

Why is that? I would expect the trap to be evaluated in the
context of the read_timeout function equivalent to an
"eval 'printf "timed out\n"; return'" inside the function and
bash, pdksh and dash/ash do that.
(I know both about read -t, but I'm trying to build something
equivalent using only SUSv3 specified functionality.)
-- 
Guido Berhoerster
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to