LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-01-2006, 01:22 PM   #1
erwinfletch
LQ Newbie
 
Registered: Jan 2006
Posts: 17

Rep: Reputation: 0
send arguments to a sigaction handler


Hi-

Is it possible to send arguments to the sigaction handler? Here is my code:

Code:
void TimerProc(int isg, siginfo_t *info, void *flag)
{
    // I want to access variables from main here with out having to make them global.  Is this possible?
    timerExpired = true; // how do I pass timerExpired to the handler?
}

int main()
{

    bool timerExpired = false;

    struct sigaction sact;
    struct itimerval value;

    memset (&sact, 0, sizeof(sact));
    sact.sa_sigaction = &TimerProc; // how do I pass timerExpired to the handler?
    sigaction (SIGVTALRM, &sact, NULL);

    value.it_interval.tv_sec = 0;
    value.it_interval.tv_usec = 15000;
    value.it_value.tv_sec = 0;
    value.it_value.tv_usec = 15000;

    result = setitimer( ITIMER_VIRTUAL, &value, NULL );
}
 
Old 05-01-2006, 07:19 PM   #2
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Signals are asynchronous events. All three arguments to the signal handler are set by the kernel. If you want the signal handler to be aware of certain conditions, use global variables. Declare them like "volatile sig_atomic_t foobar;" so any fetch/set operation on the variable is atomic (ie, it won't be interrupted in the middle of the operation if it takes +1 instructions).
 
  


Reply

Tags
signal handler


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sigaction() - how to create custom signals? rose_bud4201 Programming 22 08-20-2015 09:22 AM
SIGSEGV handler (segmentation fauld handler) myp Programming 8 03-08-2011 02:17 PM
RS232 programming (sigaction problem) lucky6969b Linux - Networking 2 04-05-2008 02:06 PM
Should I use signal() or sigaction()? .... grupoapunte Programming 2 06-04-2005 11:46 PM
<0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing mrb Linux - Newbie 2 01-09-2005 09:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration