libgst: Fix SIGALRM race and cancel a timer before starting a new one

The below Smalltalk code could trigger a race condition. We would program
a timer and then program another one before the first has expired. If the
original timer expires after we have set signal handler but before the
syscall to set the new timer was called. We could receive SIGALARM and
our signal handler would set SIG_DFL as the handler for SIGALARM. When
the new expiration is set and expires the default handler will terminate
the process.

Setting the application to SIG_IGN the handled signal could lead to a
deadlock as the real expiration is never signalled to the Smalltalk
side.

The best approach seems to cancel the timer. Before we have canceled
the timer we might run through the signal handler and signal the
original sempahore but that appears to be fine as we will not miss
an event or revert the signal handler too early. It might be best to
combine "TimeoutSem initialize" of Delay class>>#handleDelayRequstor
with the cancelation of the timer.

I have only verified the working of the posix timer (timer_settime)
and not the old interface.

Eval [
        | sem a |
        sem := Semaphore new.

        a := [
                [
                (Delay forMilliseconds: 250) wait.
                sem signal.
                ] repeat.
        ] fork.

        b := [
                [
                (Delay forMilliseconds: 125) timedWaitOn: sem.
                ] repeat.
        ] fork.

        c := [
                [
                (Delay forMilliseconds: 125) timedWaitOn: sem.
                ] repeat.
        ] fork.

        stdin next.
]

2014-09-26  Holger Hans Peter Freyther  <holger@freyther.de>

	* sysdep.h: Declare _gst_sigalrm_cancel.
	* sysdep/posix/events.c: Call _gst_sigalrm_cancel.
	* sysdep/posix/timer.c: Implement _gst_sigalrm_cancel.