/*
    ####             #    #     # #
    #   #            #    #       #          The FreeWare C library for
    #   #  ##   ###  #  # #     # ###             RISC OS machines
    #   # #  # #     # #  #     # #  #   ___________________________________
    #   # ####  ###  ##   #     # #  #
    #   # #        # # #  #     # #  #    Please refer to the accompanying
    ####   ### ####  #  # ##### # ###    documentation for conditions of use
    ________________________________________________________________________

    File:    Error2.Signal.c
    Author:  Copyright  1995 Julian Smith
    Version: 1.01 (07 Nov 1995)
    Purpose: Makes signals be handled with the Error2 system.
    History: 1.00 (08 Sep 1995)
             1.01 (07 Nov 1995)
             The handler now calls signal() so that the system
             copes with more than just the first signal...
*/

#include <signal.h>

#include "kernel.h"

#include "Desk.Error2.h"


void	Desk_Error2_SignalHandler( int signalnumber)
{
signal( signalnumber, &Desk_Error2_SignalHandler);
/*
Signals are reset to default handler when they occur, so we need to call
signal() again so that subsequent signals are also sent to this
function.
 */

Desk_Error2_ClearErrorBlock( &Desk_Error2_globalblock);

if ( signalnumber == SIGOSERROR)	Desk_Error2_CheckOS( _kernel_last_oserror());

else	{
	Desk_Error2_globalblock.type		= Desk_error2_type_SIGNAL;
	Desk_Error2_globalblock.data.signal	= signalnumber;
	Desk_Error2_Handle( &Desk_Error2_globalblock);
	}
}
