On Mon, Mar 18, 2013 at 3:24 PM, David Korn <[email protected]> wrote:
> 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.
Which pieces are missing?
>
> However, for the SIGCHLD trap, if it were implemented, it would show
> who sent the signal, not the process that terminated.
Is that really true?
/usr/include/bits/siginfo.h on Linux has SIGCHLD siginfo defined as:
/* SIGCHLD. */
struct
{
__pid_t si_pid; /* Which child. */
__uid_t si_uid; /* Real user ID of sending process. */
int si_status; /* Exit value or signal. */
__clock_t si_utime;
__clock_t si_stime;
} _sigchld;
> A user could
> send SIGINT to another process.
???
>
> However, currently, $! is set to the pid of the terminated process
> that triggered the SIGCHLD trap.
right, that's what's in siginfo si_pid.
Irek
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users