Problem using alarm() / SIGALRM

Problem using alarm() / SIGALRM

Post by Andreas Fest » Tue, 04 Jun 1996 04:00:00



Hi,

I have a problem with SIGALRM and alarm(). I need to write a program
which has to terminate itself after 60 sec. So i catched the SIGALRM
signal and called alarm(60). The main loop of the program does some
sleep()-ing and some synchronisation with another process using
semaphores. The problem is that my alarm handler is not always called.
Now i wonder if this is a linux-specific problem because the program
seems to work well under DEC Ultrix. I suspected a problem with
non-interruptable system calls, but there seems to be another problem.
I currently use Kernel Version 1.2.8 and GCC 2.6.3.
Any hints are welcome :-)

Thanks in advance

                        Andreas

--
----------------------------------------------------------------------
    ___-___  o==o=======  . . . . .  Andreas Fester
  =========== ||//                   Fachhochschule Karlsruhe
          \ \_|//__                  Germany

...to boldly go where no one has gone before
----------------------------------------------------------------------

 
 
 

Problem using alarm() / SIGALRM

Post by Jimmy Hedm » Wed, 05 Jun 1996 04:00:00



Quote:> Hi,
Hello.

> I have a problem with SIGALRM and alarm(). I need to write a program
> which has to terminate itself after 60 sec. So i catched the SIGALRM
> signal and called alarm(60). The main loop of the program does some
> sleep()-ing and some synchronisation with another process using

There's your problem. Sleep is using the alarm signal, but that is
implementation dependent so that's probably why it works under DEC Ultrix.

See chapter 10 in 'Advanced Programming in the UNIX Environmet', by
W. Richard Stevens.

--
---
Jimmy Hedman, System Manager
Erisoft AB