signal hendlers
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > signal hendlers




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    signal hendlers  
Wojciech Potyka


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10: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







[ Post a follow-up to this message ]



    Re: signal hendlers  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10: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.




[ Post a follow-up to this message ]



    Re: signal hendlers  
Michael Kerrisk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:30 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register