![]() ![]() |
![]() |
File: [Pegasus] / pegasus / src / Pegasus / Common / Signal.cpp
(download)
Revision: 1.13, Sun Sep 1 17:18:23 2002 UTC (21 years, 10 months ago) by kumpf Branch: MAIN CVS Tags: mday-2-0-patches, VERSION_2_1_RELEASE_HEAD, VERSION_2_1_RELEASE_BRANCH, VERSION_2_1_RELEASE, VERSION_2_1_1_RELEASE, LOCAL_ASSOCPROV-ROOT, LOCAL_ASSOCPROV-BRANCH Changes since 1.12: +1 -1 lines HP-DME: Split configuration files for HPUX PARISC and HPUX IA64 builds. |
//%///////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, // The Open Group, Tivoli Systems // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //============================================================================== // // Author: Markus Mueller (markus_mueller@de.ibm.com // // Modified By: // //%///////////////////////////////////////////////////////////////////////////// #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Signal.h> #include <Pegasus/Common/IPC.h> #include <Pegasus/Common/Config.h> #include <Pegasus/Common/InternalException.h> #include <cstdio> #if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) #include <unistd.cleinc> #else #include <unistd.h> #endif void sig_act(int s_n, siginfo_t * s_info, void * sig) { void * retval = NULL; printf("Received a segmentation fault\n"); #if !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) printf(" in address %p\n", s_info->si_addr); #endif printf(" pid %d\n", getpid()); // in general it is dangerous to call pthread call // from within a signal handler, because // they are not signal safe pthread_exit(retval); } void * segmentation_faulter(void * parm) { #if !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) int * dataspace; printf("my pid is %d\n", getpid()); dataspace = (int *) sbrk(0); dataspace++; *dataspace = 16; #endif return NULL; } PEGASUS_NAMESPACE_BEGIN SignalHandler::SignalHandler() : reg_mutex() { for(Uint32 i=0;i < 32;i++) { reg_handler[i].active = 0; reg_handler[i].sh = NULL; memset(®_handler[i].oldsa,0,sizeof(struct sigaction)); } } SignalHandler::~SignalHandler() { deactivateAll(); } void SignalHandler::registerHandler(Uint32 signum, signal_handler _sighandler) { reg_mutex.lock(pegasus_thread_self()); deactivate_i(signum); reg_handler[signum].sh = _sighandler; reg_mutex.unlock(); } void SignalHandler::activate(Uint32 signum) { reg_mutex.lock(pegasus_thread_self()); if (reg_handler[signum].active) return; // throw exception struct sigaction * sig_acts = new struct sigaction; sig_acts->sa_sigaction = reg_handler[signum].sh; sigfillset(&(sig_acts->sa_mask)); #if defined(PEGASUS_PLATFORM_AIX_RS_IBMCXX) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_PLATFORM_HPUX_ACC) || defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) sig_acts->sa_flags = SA_SIGINFO | SA_RESETHAND; #else sig_acts->sa_flags = SA_SIGINFO | SA_ONESHOT; #if !defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) sig_acts->sa_restorer = NULL; #endif #endif sigaction(signum, sig_acts, ®_handler[signum].oldsa); reg_handler[signum].active = -1; reg_mutex.unlock(); delete sig_acts; } void SignalHandler::deactivate(Uint32 signum) { reg_mutex.lock(pegasus_thread_self()); deactivate_i(signum); reg_mutex.unlock(); } void SignalHandler::deactivate_i(Uint32 signum) { if (reg_handler[signum].active) { reg_handler[signum].active = 0; sigaction(signum, ®_handler[signum].oldsa, NULL); } } void SignalHandler::deactivateAll() { reg_mutex.lock(pegasus_thread_self()); for (Uint32 i=0; i < 32; i++) if (reg_handler[i].active) deactivate_i(i); reg_mutex.unlock(); } void SignalHandler::ignore(Uint32 signum) { #if !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) ::sigignore(signum); #else struct sigaction * sig_acts = new struct sigaction; sig_acts->sa_handler = SIG_IGN; sigfillset(&(sig_acts->sa_mask)); sig_acts->sa_flags = 0; sigaction(signum, sig_acts, NULL); delete sig_acts; #endif } // export the global signal handling object SignalHandler _globalSignalHandler; SignalHandler * _globalSignalHandlerPtr = &_globalSignalHandler; SignalHandler * getSigHandle() { return _globalSignalHandlerPtr; } PEGASUS_NAMESPACE_END
No CVS admin address has been configured |
Powered by ViewCVS 0.9.2 |