Re: Is this is an alarm or a signal handler
From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 04/30/04
- Next message: Måns Rullgård: "Re: Is this is an alarm or a signal handler"
- Previous message: Marc Rochkind: "Re: Curses and child processes"
- In reply to: LeTubs: "Re: Is this is an alarm or a signal handler"
- Next in thread: Måns Rullgård: "Re: Is this is an alarm or a signal handler"
- Reply: Måns Rullgård: "Re: Is this is an alarm or a signal handler"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Apr 2004 00:09:59 -0400
In article <uWikc.46$zz5.30@newsfe2-gui.server.ntli.net>,
"LeTubs" <dlaw001@yahoonospam.co.uk> wrote:
> What I'm trying to is to start a timer, then a some time later
> determine if the timer counter has expired...if not wait untill
> that timer has expired.
> Now I don't know if this type of impletation is a signal/Alarm handler
> or something else. However thanks for the info
Establish a handler for the SIGALRM signal; the handler should set a
variable. Call alarm() -- it will set up a timer that will cause that
signal to be sent when the timer expires. Later, check the variable to
see if it has the value that the handler sets. If not, it means the
timer hasn't expired; call sigwait() to wait for the signal to interrupt
you.
Actually, I think it's probably easier without the timer. Start by
saving the time in a variable. Then some time later, get the current
time and compare it to the saved time. If the difference is less than
the expire time, call sleep() to wait for the remainder of the time.
-- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***
- Next message: Måns Rullgård: "Re: Is this is an alarm or a signal handler"
- Previous message: Marc Rochkind: "Re: Curses and child processes"
- In reply to: LeTubs: "Re: Is this is an alarm or a signal handler"
- Next in thread: Måns Rullgård: "Re: Is this is an alarm or a signal handler"
- Reply: Måns Rullgård: "Re: Is this is an alarm or a signal handler"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|