01-23-04 10:21 PM
On Sun, 28 Dec 2003 22:11:37 +0100, "Wojciech Potyka"
<wojtek@netprovidence.com> wrote:
quote:
>Hello
>
>I need use in signal handler function some data structure, but I dont know
>how.
>I have something like this:
>
>#ifdef SA_SIGINFO
> act.sa_flags |= SA_SIGINFO;
>#endif
> in my Signal() implementation ; it gives me that signal handler function
>have 2 new parameters
>First is siginfo_t structure pointer but i dont know what type is secound ?
>
>void sig_chld(int sig, struct siginfo_t *x, ???)
>
>Next problem is how to copy or point data structure , which i want to give
>my signal handler function,
>a dont know how the siginfo_t structure looks like?
>
>
>Resoult should be like that:
>
>void sig_chld(int sig, struct siginfo_t *x, ???);
> Signal(SIGCHLD,sig_chld,my_data_structur
e);
>
>And x should point to my data?
>
>Thanks Wojtek
As pointed out by Casper Dik, you can't do this. However, it's
possible that you may be able to do something like what you want using
real-time signals (supported on most modern Unix implementations):
1. Esatablish the handler using SA_SIGINFO, setting the sa_sigaction
field to point to your handler.
2. Send the (real-time) signal using siqqueue(pid, sig, value). The
'value' argument is a union which may contain either an integer or a
pointer which is included in the siginfo_t structure passed to the
signal handler.
3. The signal handler can look at the data sent with sigqueue using
the si_value.sival_int or si_value.sival_ptr fields.
Cheers,
Michael
[ Post a follow-up to this message ]
|