cc: [email protected]
Subject: Re: [ast-users] Trouble with .sh.sig and SIGCHLD traps
--------

> I found this very cool but undocumented (why?) feature that you can
> find the sender of a signal and pass a value (for realtime signals):
> ~/bin/ksh -c 'compound pc ; trap "pc.value=\${.sh.sig.value}
> pc.pid=\${.sh.sig.pid}" RTMIN ; integer thispid=$$ ; kill -q 16#23456
> -RTMIN $thispid &  ; wait ; printf "%s\n" "${pc}"'
> (
>         pid=984
>         value=16#23456
> )
> 
> Now I thought this could be used create scripts which handle SIGCHLD
> in an event-driven manner, but the concept doesn't work for SIGCHLD
> traps:
> ~/bin/ksh -c 'compound pc=( integer value=-1 pid=-1 ) ; trap
> "pc.value=\${.sh.sig.value} pc.pid=\${.sh.sig.pid} ; print trapCHLD"
> CHLD ; integer thispid=$$ ; sleep 2 &  ; wait ; printf "%s\n" "${pc}"'
> trapCHLD
> (
>         typeset -l -i pid=0
>         typeset -l -i value=0
> )
> 
> Why does that happen?
> 

This feature is undocumented because it is incomplete.

However, for the SIGCHLD trap, if it were implemented, it would show
who sent the signal, not the process that terminated.  A user could
send SIGINT to another process.

However, currently, $! is set to the pid of the terminated process
that triggered the SIGCHLD trap.

David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to