root/src/bb_signals.c

Revision 9ddcf89646f44d086e87d04e769f3b4480b6bcab, 2.5 kB (checked in by Philip Herron <redbrain@…>, 2 years ago)

some cleanups and added output of the pid on startup

  • Property mode set to 100644
Line 
1/**
2 * bb_signals.c -> Part of Crules Programming language
3 *
4 * Crules is the legal property of its developers. Please refer to the
5 * COPYRIGHT file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21#ifdef HAVE_CONFIG_H
22# include "config.h"
23#else
24# define CMAKE 1
25# include "config.h.cmake"
26#endif
27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <signal.h>
32
33#include <crules/crules.h>
34#include <crules/opcodes.h>
35#include <crules/symbols.h>
36#include <crules/objects.h>
37#include <crules/backend.h>
38#include <crules/runtime.h>
39#include <crules/garbage.h>
40#include <crules/operators.h>
41
42
43/*
44  SIGHUP        Hangup  POSIX   
45  SIGINT        Interrupt       ANSI
46  SIGQUIT       Quit    POSIX
47  SIGILL        Illegal instruction     ANSI
48  SIGABRT       Abort   ANSI
49  SIGTRAP       Trace trap      POSIX
50  SIGIOT        IOT trap        4.2 BSD
51  SIGEMT        EMT trap        4.2 BSD
52  SIGFPE        Floating-point exception        ANSI
53  SIGKILL       Kill, unblock-able      POSIX
54  SIGBUS        Bus error       4.2 BSD
55  SIGSEGV       Segmentation violation  ANSI
56  SIGSYS        Bad argument to system call     4.2 BSD
57  SIGPIPE       Broken pipe     POSIX
58  SIGALRM       Alarm clock     POSIX
59  SIGTERM       Termination     ANSI
60  SIGUSR1       User-defined signal 1   POSIX
61  SIGUSR2       User-defined signal 2   POSIX
62  SIGCHLD       Child status has changed        POSIX
63  SIGCLD        Same as SIGCHLD         System V
64  SIGPWR        Power failure restart   System V
65  SIGXCPU       Exceeded CPU time       POSIX
66  SIGSTOP       Pause execution         POSIX
67  SIGCONT       Resume execution        POSIX
68*/
69
70/**
71 * Eventually need to have some kind of internal vtable
72 * to handle signals from the programs perspective and
73 * have decent POSIX behaviours
74 **/
75void crl_catch_signal( int signal )
76{
77  switch( signal )
78    {
79    case SIGINT: crl_fatal("Caught SIGINT exiting...\n");
80
81    case SIGQUIT: crl_fatal("Caught SIGQUIT exiting...\n");
82
83    case SIGTERM: crl_fatal("Caught SIGTERM exiting...\n");
84
85    default:
86      crl_fatal("Caught unhandled signal '%i' exiting...\n", signal);
87    }
88}
Note: See TracBrowser for help on using the browser.