|
Home > Archive > Unix Programming > January 2004 > signal hendlers
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Wojciech Potyka 2004-01-23, 5:21 pm |
| 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
| |
| Casper H.S. Dik 2004-01-23, 5:21 pm |
| "Wojciech Potyka" <wojtek@netprovidence.com> writes:
quote:
>void sig_chld(int sig, struct siginfo_t *x, ???)
quote:
>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?
Generally, you can't; even though the 3rd argument is a
void * it's really a process context which contains the
state at the time the signal occured.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
| |
| Michael Kerrisk 2004-01-23, 5: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
|
|
|
|
|