Results 1 to 3 of 3
I want to implement basic timer in linux, so i used signal function as like this,
void sig_alarm(int flag)
{
printf("\nthis is next string");
return;
}
int main()
{
signal(SIGALRM, ...
- 06-16-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
Implementing basic timer.
I want to implement basic timer in linux, so i used signal function as like this,
void sig_alarm(int flag)
{
printf("\nthis is next string");
return;
}
int main()
{
signal(SIGALRM, sig_alarm);
printf("\nthis is first string");
alarm(10);
return 0;
}
I want to show 2nd printf after 10 seconds. Is I missing something in this? It shows only first printf and then exits.
Help Plz.!!
- 06-16-2008 #2
Alarms (and other signals) are caught only while your program is actually running. What you've done is to set up a signal catcher, set up the alarm, and then exit your program. It's simply done computing.
Give it something to do after the alarm() string, something that takes more than 10 seconds to complete.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 06-17-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
Thanks Bill, I got it.!!


Reply With Quote