1 /* signal.h -*- C++ -*- 2 $Id: signal.h,v 1.1 1997/10/12 19:57:37 elf Exp $ 3 4 written by Marc Singer 5 19 Oct 1996 6 7 This file is part of the project CurVeS. See the file README for 8 more information. 9 10 Copyright (C) 1996 Marc Singer 11 12 This program is free software; you can redistribute it and/or 13 modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation; either version 2 of the 15 License, or (at your option) any later version. 16 17 This program is distributed in the hope that it will be useful, but 18 WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 in a file called COPYING along with this program; if not, write to 24 the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 25 02139, USA. 26 27 */ 28 29 #if !defined (__SIGNAL_H__) 30 # define __SIGNAL_H__ 31 32 /* ----- Includes */ 33 34 #include <signal.h> 35 36 /* ----- Globals */ 37 38 typedef void* LSignalHandle; // Encapsulated signal handle 39 typedef void (*LSignalHandler) (LSignalHandle, 40 void*); // Encapsulated signal handler 41 42 typedef struct _LSignalHandlerInstance { 43 struct _LSignalHandlerInstance* pNext; // Link pointer (must be first) 44 LSignalHandler pfn; // Caller's function pointer 45 void* pv; // Caller's context pointer 46 int rank; // Handler's rank among like handlers 47 int flags; // Some flags, if we need them 48 } LSignalHandlerInstance; 49 50 51 class LSignal { 52 protected: 53 static LSignalHandlerInstance* g_rgpHandler[NSIG]; 54 static struct sigaction g_rgAction[NSIG]; 55 static sigset_t g_setEnable; // Set when our handler is enabled 56 57 static void handler (int signal); // Reentrant, OS signal handler 58 59 static void disable (int signal); 60 static void enable (int signal); 61 62 static void block (int signal); 63 static void unblock (int signal); 64 65 public: 66 static int accept (int signal, LSignalHandler pfn, void* pv, 67 int rank, int flags); 68 static int release (int signal, LSignalHandler pfn, void* pv); 69 static int signal_of (LSignalHandle handle); 70 }; 71 72 73 #endif /* __SIGNAL_H__ */ 74