(file) Return to Signal.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 martin 1.28 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.29 //
  3 martin 1.28 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.29 //
 10 martin 1.28 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.29 //
 17 martin 1.28 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.29 //
 20 martin 1.28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.29 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.29 //
 28 martin 1.28 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32 kumpf  1.9  #ifndef Pegasus_Signal_h
 33             #define Pegasus_Signal_h
 34 mike   1.2  
 35 kumpf  1.9  #include <Pegasus/Common/Linkage.h>
 36 mike   1.23 #include <Pegasus/Common/Mutex.h>
 37 mike   1.3  
 38 kumpf  1.9  #ifdef PEGASUS_HAS_SIGNALS
 39             
 40             # include <signal.h>
 41             typedef siginfo_t PEGASUS_SIGINFO_T;
 42 marek  1.26 # define PEGASUS_SIGHUP    SIGHUP
 43             # define PEGASUS_SIGABRT   SIGABRT
 44             # define PEGASUS_SIGPIPE   SIGPIPE
 45             # define PEGASUS_SIGTERM   SIGTERM
 46             # define PEGASUS_SIGUSR1   SIGUSR1
 47             # define PEGASUS_SIGCHLD   SIGCHLD
 48             # define PEGASUS_SIGDANGER SIGDANGER
 49 kumpf  1.9  
 50             #else // PEGASUS_HAS_SIGNALS
 51             
 52             typedef void PEGASUS_SIGINFO_T;
 53 marek  1.26 # define PEGASUS_SIGHUP    1
 54             # define PEGASUS_SIGABRT   11
 55             # define PEGASUS_SIGPIPE   13
 56             # define PEGASUS_SIGTERM   15
 57             # define PEGASUS_SIGUSR1   16
 58             # define PEGASUS_SIGCHLD   18
 59             # define PEGASUS_SIGDANGER 33
 60 kumpf  1.9  
 61             #endif // PEGASUS_HAS_SIGNALS
 62             
 63 mike   1.2  
 64 sage   1.6  extern "C" {
 65 kumpf  1.27     typedef void (* signal_handler)(int, PEGASUS_SIGINFO_T *, void *);
 66 sage   1.6  }
 67 mike   1.2  
 68             PEGASUS_NAMESPACE_BEGIN
 69             
 70             class PEGASUS_COMMON_LINKAGE SignalHandler
 71             {
 72 david.dillard 1.18 public:
 73                        SignalHandler();
 74 mike          1.2  
 75 david.dillard 1.18     ~SignalHandler(); // deactivate all registered handlers
 76 mike          1.2  
 77 david.dillard 1.18     // these functions should throw exceptions
 78 mike          1.2  
 79 kumpf         1.27     /**
 80                            Registers a signal handler.
 81                            @param signum The signal number for which to register the handler.
 82                            @sighandler The signal handler to register
 83                            @exception IndexOutOfBoundsException if signum is outside the range
 84                                of signals supported by the SignalHandler (see PEGASUS_NSIG).
 85                        */
 86                        void registerHandler(unsigned signum, signal_handler sighandler);
 87                    
 88                        /**
 89                            Activates a signal handler.
 90                            @param signum The signal number for which to activate the handler.
 91                            @exception IndexOutOfBoundsException if signum is outside the range
 92                                of signals supported by the SignalHandler (see PEGASUS_NSIG).
 93                        */
 94 david.dillard 1.20     void activate(unsigned signum);
 95 mike          1.2  
 96 kumpf         1.27     /**
 97                            Deactivates a signal handler.
 98                            @param signum The signal number for which to deactivate the handler.
 99                            @exception IndexOutOfBoundsException if signum is outside the range
100                                of signals supported by the SignalHandler (see PEGASUS_NSIG).
101                        */
102 david.dillard 1.20     void deactivate(unsigned signum);
103 mike          1.2  
104 david.dillard 1.18     void deactivateAll();
105 mike          1.2  
106 kumpf         1.27     /**
107                            Sets a signal action to "ignore".
108                            @param signum The signal number to ignore.
109                            @exception IndexOutOfBoundsException if signum is outside the range
110                                of signals supported by the SignalHandler (see PEGASUS_NSIG).
111                        */
112 david.dillard 1.20     static void ignore(unsigned signum);
113 mike          1.2  
114 kumpf         1.27     /**
115                            Resets a signal action to its default.
116                            @param signum The signal number for which to reset the signal action.
117                            @exception IndexOutOfBoundsException if signum is outside the range
118                                of signals supported by the SignalHandler (see PEGASUS_NSIG).
119                        */
120 mateus.baur   1.25     static void defaultAction(unsigned signum);
121                    
122 david.dillard 1.18 private:
123 mike          1.2  
124 kumpf         1.9  #ifdef PEGASUS_HAS_SIGNALS
125 david.dillard 1.20     enum
126                        {
127 marek         1.26         PEGASUS_NSIG = 33
128 david.dillard 1.20     };
129                    
130                        static void verifySignum(unsigned signum);
131 kumpf         1.9  
132 david.dillard 1.18     typedef struct {
133                            int signum;
134                            int active;
135                            signal_handler sh;
136                            struct sigaction oldsa;
137                        } register_handler;
138 mike          1.2  
139 david.dillard 1.18     register_handler reg_handler[PEGASUS_NSIG + 1];
140                        Mutex reg_mutex;
141                    
142 david.dillard 1.19     void deactivate_i(register_handler &rh);
143 david.dillard 1.18 
144 david.dillard 1.20     register_handler &getHandler(unsigned sigum);
145 kumpf         1.9  #endif
146 mike          1.2  
147                    };
148                    
149 kumpf         1.12 PEGASUS_COMMON_LINKAGE SignalHandler * getSigHandle();
150 mike          1.2  
151                    PEGASUS_NAMESPACE_END
152                    
153 kumpf         1.9  #endif // Pegasus_Signal_h

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2