Re: wait()/alarm() race condition

2003-03-31 Thread Peter Edwards
> Greetings, > > I have a loop which calls wait(), and I want another function to be > called > as close to once per minute as possible. Pseudo code: > [snip example] > > My concern is there is a small possibility that the alarm signal is > delivered after the if() but before the wait. So it is

Re: wait()/alarm() race condition

2003-03-30 Thread Brian Buchanan
On Sun, 30 Mar 2003, [ISO-8859-1] Mikko Työläjärvi wrote: > On Sun, 30 Mar 2003, Sean Hamilton wrote: > > > Dan Nelson wrote: > > | Just make sure your signal handler has the SA_RESTART flag unset > > | (either via siginterrupt() if the handler was installed with signal(), > > | or directly if the

Re: wait()/alarm() race condition

2003-03-30 Thread Sean Hamilton
Dan Nelson wrote: | In the last episode (Mar 30), Sean Hamilton said: || I'm concerned about this order of events: || || - alarm() || - wait() returns successfully || - if (alarmed...) [false] || - SIGALRM is delivered, alarmed = true || - loop || - wait() waits indefinitely | | A cleaner solution

Re: wait()/alarm() race condition

2003-03-30 Thread Dan Nelson
In the last episode (Mar 30), Sean Hamilton said: > Dan Nelson wrote: > | Just make sure your signal handler has the SA_RESTART flag unset > | (either via siginterrupt() if the handler was installed with > | signal(), or directly if the signal was installed with sigaction() > | ), and the signal wi

Re: wait()/alarm() race condition

2003-03-30 Thread Mikko Työläjärvi
On Sun, 30 Mar 2003, Sean Hamilton wrote: > Dan Nelson wrote: > | Just make sure your signal handler has the SA_RESTART flag unset > | (either via siginterrupt() if the handler was installed with signal(), > | or directly if the signal was installed with sigaction() ), and the > | signal will inte

Re: wait()/alarm() race condition

2003-03-30 Thread Sean Hamilton
Dan Nelson wrote: | Just make sure your signal handler has the SA_RESTART flag unset | (either via siginterrupt() if the handler was installed with signal(), | or directly if the signal was installed with sigaction() ), and the | signal will interrupt the wait() call. Er, I think you've missed my

Re: wait()/alarm() race condition

2003-03-30 Thread Dan Nelson
In the last episode (Mar 30), Sean Hamilton said: > [asked in comp.unix.programmer without much luck] > > I have a loop which calls wait(), and I want another function to be > called as close to once per minute as possible. Pseudo code: [snip] > My concern is there is a small possibility that the

wait()/alarm() race condition

2003-03-30 Thread Sean Hamilton
[asked in comp.unix.programmer without much luck] Greetings, I have a loop which calls wait(), and I want another function to be called as close to once per minute as possible. Pseudo code: int alarmed = 0; void handle_sigalrm (int sig) { alarmed = 1; } while (1) { alarmed = 0; ala