version 1.8, 2002/08/17 00:59:36
|
version 1.23, 2006/08/09 21:12:42
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Markus Mueller (markus_mueller@de.ibm.com |
// Author: Markus Mueller (markus_mueller@de.ibm.com) |
// | // |
// Modified By: |
// Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// : Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
#ifndef Pegasus_Signal_h |
|
#define Pegasus_Signal_h |
| |
#ifndef Pegasus_SignalHandler_h |
#include <Pegasus/Common/Linkage.h> |
#define Pegasus_SignalHandler_h |
#include <Pegasus/Common/Mutex.h> |
|
|
// REVIEW: Where is this signal handling code used? |
|
|
|
// REVIEW: Is there an equivalent implementation for Windows? |
|
|
|
| |
// // Ensure Unix 98 | // // Ensure Unix 98 |
// #ifdef PEGASUS_PLATFORM_LINUX_IX86_GNU | // #ifdef PEGASUS_PLATFORM_LINUX_IX86_GNU |
|
|
// #define _XOPEN_SOURCE 600 | // #define _XOPEN_SOURCE 600 |
// #endif | // #endif |
| |
|
#ifdef PEGASUS_HAS_SIGNALS |
|
|
#include <signal.h> | #include <signal.h> |
|
typedef siginfo_t PEGASUS_SIGINFO_T; |
|
# define PEGASUS_SIGHUP SIGHUP |
|
# define PEGASUS_SIGABRT SIGABRT |
|
# define PEGASUS_SIGPIPE SIGPIPE |
|
# define PEGASUS_SIGTERM SIGTERM |
|
# define PEGASUS_SIGUSR1 SIGUSR1 |
|
# define PEGASUS_SIGCHLD SIGCHLD |
|
|
|
#else // PEGASUS_HAS_SIGNALS |
|
|
|
typedef void PEGASUS_SIGINFO_T; |
|
# define PEGASUS_SIGHUP 1 |
|
# define PEGASUS_SIGABRT 11 |
|
# define PEGASUS_SIGPIPE 13 |
|
# define PEGASUS_SIGTERM 15 |
|
# define PEGASUS_SIGUSR1 16 |
|
# define PEGASUS_SIGCHLD 18 |
|
|
|
#endif // PEGASUS_HAS_SIGNALS |
| |
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
|
|
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || (PEGASUS_OS_SOLARIS) |
extern "C" { | extern "C" { |
#endif | #endif |
| |
typedef void (* signal_handler)(int,siginfo_t *,void *); |
typedef void (* signal_handler)(int, PEGASUS_SIGINFO_T *, void *); |
|
|
typedef struct { |
|
int active; |
|
signal_handler sh; |
|
struct sigaction oldsa; |
|
} register_handler; |
|
| |
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || (PEGASUS_OS_SOLARIS) |
} | } |
#endif | #endif |
| |
#include <Pegasus/Common/Thread.h> |
// Sample signal handler for SIGABRT that stops the failing thread normally |
#include <Pegasus/Common/DQueue.h> |
void sig_act(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig); |
#include <Pegasus/Common/InternalException.h> |
|
#include <Pegasus/Common/Linkage.h> |
|
|
|
// used locally as standard response to stop the failing thread normally |
|
void sig_act(int s_n, siginfo_t * s_info, void * sig); |
|
// test routine, that just causes a segmentation fault |
|
void * segmentation_faulter(void * parm); |
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
| |
// these functions should throw exceptions | // these functions should throw exceptions |
| |
void registerHandler(Uint32 signum, signal_handler _sighandler); |
void registerHandler(unsigned signum, signal_handler _sighandler); |
| |
void activate(Uint32 signum); |
void activate(unsigned signum); |
| |
//void activateAll(); | //void activateAll(); |
| |
void deactivate(Uint32 signum); |
void deactivate(unsigned signum); |
| |
void deactivateAll(); | void deactivateAll(); |
| |
static void ignore(Uint32 signum); |
static void ignore(unsigned signum); |
| |
private: | private: |
| |
register_handler reg_handler[32]; |
#ifdef PEGASUS_HAS_SIGNALS |
|
enum |
|
{ |
|
PEGASUS_NSIG = 32 |
|
}; |
|
|
|
static void verifySignum(unsigned signum); |
|
|
|
typedef struct { |
|
int signum; |
|
int active; |
|
signal_handler sh; |
|
struct sigaction oldsa; |
|
} register_handler; |
|
|
|
register_handler reg_handler[PEGASUS_NSIG + 1]; |
Mutex reg_mutex; | Mutex reg_mutex; |
| |
void deactivate_i(Uint32 signum); |
void deactivate_i(register_handler &rh); |
|
|
|
register_handler &getHandler(unsigned sigum); |
|
#endif |
| |
}; | }; |
| |
SignalHandler * getSigHandle(); |
PEGASUS_COMMON_LINKAGE SignalHandler * getSigHandle(); |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif // Pegasus_SignalHandler_h |
#endif // Pegasus_Signal_h |