How do you force a function to both inherit signals and accept local
variables?
$ ksh -c 'function f { typeset x=${.sh.fun}; trap "print -r caught in \$x"
USR1; g; print -r "returning with $x"; }; function g { typeset x=${.sh.fun};
sleep 5; }; f & sleep 1; kill -s USR1 $!'
returning with f
$ ksh -c 'function f { typeset x=${.sh.fun}; trap "print -r caught in \$x"
USR1; . g; print -r "returning with $x"; }; function g { typeset x=${.sh.fun};
sleep 5; }; f & sleep 1; kill -s USR1 $!'
caught in f
returning with f
Desired output is:
caught in g
returning with f
I'm aware you can reset the trap within each function called from f, but that
isn't the same logic (if called from a different function that doesn't set the
trap) and probably implies a race condition until the function sets its own
handler.
--
Dan Douglas
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users