LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-11-2009, 04:24 AM   #1
shylendra.kumar
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
The terminal receives -1 after signal handler is invoked on timer expire.


I have written a small program to set the elapse timer using posix calls timer_create & timer_settime. Associated the notification as SIGEV_SIGNAL.
The signal handler is invoked but after the completion of signal handler i could see that the terminal associated with the process gets -1.


Can any one tell what might be the problem and how do i solve this.
I am using this program to do a interacting test suite.

Last edited by shylendra.kumar; 09-11-2009 at 06:11 AM.
 
Old 09-11-2009, 04:27 AM   #2
shylendra.kumar
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shylendra.kumar View Post
I have written a small program to set the elapse timer using posix calls timer_create & timer_settime. Associated the notification as SIGEV_SIGNAL.
The signal handler is invoked but after the completion of signal handler i could see that the terminal associated with the process gets -1.
Can any one tell what might be the problem and how do i solve this.
I am using this program to do a interacting test suite.
Actual piece of code
main()
{
int i = 0, rc;
struct sigevent sigVal;
struct sigaction sigAction;
timer_t timerid;
struct itimerspec timeout;
sigVal.sigev_signo = SIGALRM;
sigVal.sigev_notify = SIGEV_SIGNAL;
sigVal.sigev_value.sival_int = 100;
rc = timer_create(CLOCK_REALTIME, &sigVal, &timerid);
if(rc!=0)
{
printf("StyleGC --------- create failed \n");
return 0;
}
timeout.it_value.tv_sec = 2000/1000;
timeout.it_value.tv_nsec = 0;
timeout.it_interval.tv_sec = 1;
timeout.it_interval.tv_nsec = 0;
rc = timer_settime(timerid, CLOCK_REALTIME, &timeout, NULL);
if(rc!=0)
{
printf("StyleGC --------- SetTimer failed \n");
return 0;
}
sigAction.sa_sigaction = StyleSigHandler;
sigAction.sa_flags = SA_SIGINFO;
sigemptyset(&sigAction.sa_mask);
if(sigaction(SIGALRM, &sigAction, NULL) == -1)
{
printf("StyleGC --------- SigAction failed \n");
return 0;
}

while(1)
printf("StyleGC --- %c\n", getchar());
return 0;
}

Can any one please help me with this issue.
Thanks in advance.

Last edited by shylendra.kumar; 09-11-2009 at 06:11 AM.
 
  


Reply



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
user-define signal handler & coredump for signal 11(SIGSEGV) Alexlun Linux - Software 2 05-24-2009 06:37 AM
How to reinstall a signal handler after exec ( Strange behaviour in signal handling ) lali.p Programming 0 09-20-2008 12:11 PM
Monitor receives no signal Linkhiei Linux - Hardware 9 05-21-2006 09:54 PM
Timer Interrupt Handler opereira Programming 1 03-03-2004 04:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:52 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