mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: protect headers against multiple inclusion in POSIX/signals
STYLE: report when SIGFPE handling is unsupported - move OSspecific.H include from signal headers to argList where it is more obvious
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,9 +23,8 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
#include "sigFpe.H"
|
#include "sigFpe.H"
|
||||||
|
#include "error.H"
|
||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
@ -52,51 +51,42 @@ License
|
|||||||
struct sigaction Foam::sigFpe::oldAction_;
|
struct sigaction Foam::sigFpe::oldAction_;
|
||||||
|
|
||||||
|
|
||||||
#if defined(LINUX)
|
#ifdef LINUX
|
||||||
|
|
||||||
void *(*Foam::sigFpe::old_malloc_hook)(size_t, const void *) = NULL;
|
void *(*Foam::sigFpe::oldMallocHook_)(size_t, const void *) = NULL;
|
||||||
|
|
||||||
void* Foam::sigFpe::my_malloc_hook(size_t size, const void *caller)
|
void* Foam::sigFpe::nanMallocHook_(size_t size, const void *caller)
|
||||||
{
|
{
|
||||||
void *result;
|
void *result;
|
||||||
|
|
||||||
// Restore all old hooks
|
// Restore all old hooks
|
||||||
__malloc_hook = old_malloc_hook;
|
__malloc_hook = oldMallocHook_;
|
||||||
|
|
||||||
// Call recursively
|
// Call recursively
|
||||||
result = malloc(size);
|
result = malloc(size);
|
||||||
|
|
||||||
// initialize to signalling nan
|
// initialize to signalling NaN
|
||||||
# ifdef WM_SP
|
# ifdef WM_SP
|
||||||
|
|
||||||
const uint32_t sNAN = 0x7ff7fffflu;
|
const uint32_t sNAN = 0x7ff7fffflu;
|
||||||
|
|
||||||
int nScalars = size / sizeof(scalar);
|
|
||||||
|
|
||||||
uint32_t* dPtr = reinterpret_cast<uint32_t*>(result);
|
uint32_t* dPtr = reinterpret_cast<uint32_t*>(result);
|
||||||
|
|
||||||
for (int i = 0; i < nScalars; i++)
|
|
||||||
{
|
|
||||||
*dPtr++ = sNAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
const uint64_t sNAN = 0x7ff7ffffffffffffllu;
|
const uint64_t sNAN = 0x7ff7ffffffffffffllu;
|
||||||
|
|
||||||
int nScalars = size/sizeof(scalar);
|
|
||||||
|
|
||||||
uint64_t* dPtr = reinterpret_cast<uint64_t*>(result);
|
uint64_t* dPtr = reinterpret_cast<uint64_t*>(result);
|
||||||
|
|
||||||
for (int i = 0; i < nScalars; i++)
|
# endif
|
||||||
|
|
||||||
|
const size_t nScalars = size/sizeof(scalar);
|
||||||
|
for (size_t i = 0; i < nScalars; ++i)
|
||||||
{
|
{
|
||||||
*dPtr++ = sNAN;
|
*dPtr++ = sNAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// Restore our own hooks
|
// Restore our own hooks
|
||||||
__malloc_hook = my_malloc_hook;
|
__malloc_hook = nanMallocHook_;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -106,14 +96,14 @@ void* Foam::sigFpe::my_malloc_hook(size_t size, const void *caller)
|
|||||||
|
|
||||||
#ifdef LINUX_GNUC
|
#ifdef LINUX_GNUC
|
||||||
|
|
||||||
void Foam::sigFpe::sigFpeHandler(int)
|
void Foam::sigFpe::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
// Reset old handling
|
||||||
if (sigaction(SIGFPE, &oldAction_, NULL) < 0)
|
if (sigaction(SIGFPE, &oldAction_, NULL) < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Foam::sigSegv::sigFpeHandler()"
|
"Foam::sigSegv::sigHandler()"
|
||||||
) << "Cannot reset SIGFPE trapping"
|
) << "Cannot reset SIGFPE trapping"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -166,7 +156,7 @@ Foam::sigFpe::~sigFpe()
|
|||||||
// Reset to standard malloc
|
// Reset to standard malloc
|
||||||
if (oldAction_.sa_handler)
|
if (oldAction_.sa_handler)
|
||||||
{
|
{
|
||||||
__malloc_hook = old_malloc_hook;
|
__malloc_hook = oldMallocHook_;
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
@ -189,13 +179,10 @@ void Foam::sigFpe::set(const bool verbose)
|
|||||||
|
|
||||||
if (env("FOAM_SIGFPE"))
|
if (env("FOAM_SIGFPE"))
|
||||||
{
|
{
|
||||||
if (verbose)
|
bool supported = false;
|
||||||
{
|
|
||||||
Info<< "SigFpe : Enabling floating point exception trapping"
|
|
||||||
<< " (FOAM_SIGFPE)." << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifdef LINUX_GNUC
|
# ifdef LINUX_GNUC
|
||||||
|
supported = true;
|
||||||
|
|
||||||
feenableexcept
|
feenableexcept
|
||||||
(
|
(
|
||||||
@ -205,7 +192,7 @@ void Foam::sigFpe::set(const bool verbose)
|
|||||||
);
|
);
|
||||||
|
|
||||||
struct sigaction newAction;
|
struct sigaction newAction;
|
||||||
newAction.sa_handler = sigFpeHandler;
|
newAction.sa_handler = sigHandler;
|
||||||
newAction.sa_flags = SA_NODEFER;
|
newAction.sa_flags = SA_NODEFER;
|
||||||
sigemptyset(&newAction.sa_mask);
|
sigemptyset(&newAction.sa_mask);
|
||||||
if (sigaction(SIGFPE, &newAction, &oldAction_) < 0)
|
if (sigaction(SIGFPE, &newAction, &oldAction_) < 0)
|
||||||
@ -219,6 +206,7 @@ void Foam::sigFpe::set(const bool verbose)
|
|||||||
|
|
||||||
|
|
||||||
# elif defined(sgiN32) || defined(sgiN32Gcc)
|
# elif defined(sgiN32) || defined(sgiN32Gcc)
|
||||||
|
supported = true;
|
||||||
|
|
||||||
sigfpe_[_DIVZERO].abort=1;
|
sigfpe_[_DIVZERO].abort=1;
|
||||||
sigfpe_[_OVERFL].abort=1;
|
sigfpe_[_OVERFL].abort=1;
|
||||||
@ -240,23 +228,50 @@ void Foam::sigFpe::set(const bool verbose)
|
|||||||
);
|
);
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
if (supported)
|
||||||
|
{
|
||||||
|
Info<< "sigFpe : Enabling floating point exception trapping"
|
||||||
|
<< " (FOAM_SIGFPE)." << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "sigFpe : Floating point exception trapping"
|
||||||
|
<< " - not supported on this platform" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (env("FOAM_SETNAN"))
|
if (env("FOAM_SETNAN"))
|
||||||
{
|
{
|
||||||
|
bool supported = false;
|
||||||
|
|
||||||
|
# ifdef LINUX_GNUC
|
||||||
|
supported = true;
|
||||||
|
|
||||||
|
// Set our malloc
|
||||||
|
__malloc_hook = Foam::sigFpe::nanMallocHook_;
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
{
|
||||||
|
if (supported)
|
||||||
{
|
{
|
||||||
Info<< "SetNaN : Initialising allocated memory to NaN"
|
Info<< "SetNaN : Initialising allocated memory to NaN"
|
||||||
<< " (FOAM_SETNAN)." << endl;
|
<< " (FOAM_SETNAN)." << endl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
# ifdef LINUX_GNUC
|
{
|
||||||
|
Info<< "SetNaN : Initialise allocated memory to NaN"
|
||||||
// Set our malloc
|
<< " - not supported on this platform" << endl;
|
||||||
__malloc_hook = Foam::sigFpe::my_malloc_hook;
|
}
|
||||||
|
}
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -43,7 +43,6 @@ SourceFiles
|
|||||||
#ifndef sigFpe_H
|
#ifndef sigFpe_H
|
||||||
#define sigFpe_H
|
#define sigFpe_H
|
||||||
|
|
||||||
#include "OSspecific.H"
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#if defined(linux) || defined(linuxAMD64) || defined(linuxIA64)
|
#if defined(linux) || defined(linuxAMD64) || defined(linuxIA64)
|
||||||
@ -73,10 +72,10 @@ class sigFpe
|
|||||||
# ifdef LINUX
|
# ifdef LINUX
|
||||||
|
|
||||||
//- Saved old malloc
|
//- Saved old malloc
|
||||||
static void *(*old_malloc_hook)(size_t, const void *);
|
static void *(*oldMallocHook_)(size_t, const void *);
|
||||||
|
|
||||||
//- nan malloc function. From malloc_hook manpage.
|
//- NaN malloc function. From malloc_hook manpage.
|
||||||
static void* my_malloc_hook(size_t size, const void *caller);
|
static void* nanMallocHook_(size_t size, const void *caller);
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -86,7 +85,7 @@ class sigFpe
|
|||||||
# ifdef LINUX_GNUC
|
# ifdef LINUX_GNUC
|
||||||
|
|
||||||
//- Handler for caught signals
|
//- Handler for caught signals
|
||||||
static void sigFpeHandler(int);
|
static void sigHandler(int);
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -96,6 +95,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
sigFpe();
|
sigFpe();
|
||||||
|
|
||||||
|
|
||||||
@ -105,6 +105,8 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
|
//- Activate SIGFPE signal handler when FOAM_SIGFPE is %set
|
||||||
|
// Fill memory with NaN when FOAM_SETNAN is %set
|
||||||
void set(const bool verbose);
|
void set(const bool verbose);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,8 +23,8 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
#include "sigInt.H"
|
#include "sigInt.H"
|
||||||
|
#include "error.H"
|
||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
@ -32,16 +32,17 @@ License
|
|||||||
|
|
||||||
struct sigaction Foam::sigInt::oldAction_;
|
struct sigaction Foam::sigInt::oldAction_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sigInt::sigIntHandler(int)
|
void Foam::sigInt::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
// Reset old handling
|
||||||
if (sigaction(SIGINT, &oldAction_, NULL) < 0)
|
if (sigaction(SIGINT, &oldAction_, NULL) < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Foam::sigInt::sigIntHandler()"
|
"Foam::sigInt::sigHandler()"
|
||||||
) << "Cannot reset SIGINT trapping"
|
) << "Cannot reset SIGINT trapping"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -80,7 +81,7 @@ Foam::sigInt::~sigInt()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sigInt::set(const bool verbose)
|
void Foam::sigInt::set(const bool)
|
||||||
{
|
{
|
||||||
if (oldAction_.sa_handler)
|
if (oldAction_.sa_handler)
|
||||||
{
|
{
|
||||||
@ -92,7 +93,7 @@ void Foam::sigInt::set(const bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct sigaction newAction;
|
struct sigaction newAction;
|
||||||
newAction.sa_handler = sigIntHandler;
|
newAction.sa_handler = sigHandler;
|
||||||
newAction.sa_flags = SA_NODEFER;
|
newAction.sa_flags = SA_NODEFER;
|
||||||
sigemptyset(&newAction.sa_mask);
|
sigemptyset(&newAction.sa_mask);
|
||||||
if (sigaction(SIGINT, &newAction, &oldAction_) < 0)
|
if (sigaction(SIGINT, &newAction, &oldAction_) < 0)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -38,7 +38,9 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "OSspecific.H"
|
#ifndef sigInt_H
|
||||||
|
#define sigInt_H
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -60,13 +62,14 @@ class sigInt
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
static void sigIntHandler(int);
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
sigInt();
|
sigInt();
|
||||||
|
|
||||||
|
|
||||||
@ -76,6 +79,7 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
|
//- Activate SIGINT signal handler
|
||||||
void set(const bool verbose);
|
void set(const bool verbose);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,4 +88,8 @@ public:
|
|||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,8 +23,8 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
#include "sigQuit.H"
|
#include "sigQuit.H"
|
||||||
|
#include "error.H"
|
||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
@ -32,16 +32,17 @@ License
|
|||||||
|
|
||||||
struct sigaction Foam::sigQuit::oldAction_;
|
struct sigaction Foam::sigQuit::oldAction_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sigQuit::sigQuitHandler(int)
|
void Foam::sigQuit::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
// Reset old handling
|
||||||
if (sigaction(SIGQUIT, &oldAction_, NULL) < 0)
|
if (sigaction(SIGQUIT, &oldAction_, NULL) < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Foam::sigQuit::sigQuitHandler()"
|
"Foam::sigQuit::sigHandler()"
|
||||||
) << "Cannot reset SIGQUIT trapping"
|
) << "Cannot reset SIGQUIT trapping"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -94,7 +95,7 @@ void Foam::sigQuit::set(const bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct sigaction newAction;
|
struct sigaction newAction;
|
||||||
newAction.sa_handler = sigQuitHandler;
|
newAction.sa_handler = sigHandler;
|
||||||
newAction.sa_flags = SA_NODEFER;
|
newAction.sa_flags = SA_NODEFER;
|
||||||
sigemptyset(&newAction.sa_mask);
|
sigemptyset(&newAction.sa_mask);
|
||||||
if (sigaction(SIGQUIT, &newAction, &oldAction_) < 0)
|
if (sigaction(SIGQUIT, &newAction, &oldAction_) < 0)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -38,7 +38,9 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "OSspecific.H"
|
#ifndef sigQuit_H
|
||||||
|
#define sigQuit_H
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -60,13 +62,15 @@ class sigQuit
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
static void sigQuitHandler(int);
|
//- Handler for caught signals
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
sigQuit();
|
sigQuit();
|
||||||
|
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
|
//- Activate SIGQUIT signal handler
|
||||||
void set(const bool verbose);
|
void set(const bool verbose);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,4 +89,8 @@ public:
|
|||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,8 +23,8 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
#include "sigSegv.H"
|
#include "sigSegv.H"
|
||||||
|
#include "error.H"
|
||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
@ -32,16 +32,17 @@ License
|
|||||||
|
|
||||||
struct sigaction Foam::sigSegv::oldAction_;
|
struct sigaction Foam::sigSegv::oldAction_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sigSegv::sigSegvHandler(int)
|
void Foam::sigSegv::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
// Reset old handling
|
||||||
if (sigaction(SIGSEGV, &oldAction_, NULL) < 0)
|
if (sigaction(SIGSEGV, &oldAction_, NULL) < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Foam::sigSegv::sigSegvHandler()"
|
"Foam::sigSegv::sigHandler()"
|
||||||
) << "Cannot reset SIGSEGV trapping"
|
) << "Cannot reset SIGSEGV trapping"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -82,7 +83,7 @@ Foam::sigSegv::~sigSegv()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sigSegv::set(const bool verbose)
|
void Foam::sigSegv::set(const bool)
|
||||||
{
|
{
|
||||||
if (oldAction_.sa_handler)
|
if (oldAction_.sa_handler)
|
||||||
{
|
{
|
||||||
@ -94,7 +95,7 @@ void Foam::sigSegv::set(const bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct sigaction newAction;
|
struct sigaction newAction;
|
||||||
newAction.sa_handler = sigSegvHandler;
|
newAction.sa_handler = sigHandler;
|
||||||
newAction.sa_flags = SA_NODEFER;
|
newAction.sa_flags = SA_NODEFER;
|
||||||
sigemptyset(&newAction.sa_mask);
|
sigemptyset(&newAction.sa_mask);
|
||||||
if (sigaction(SIGSEGV, &newAction, &oldAction_) < 0)
|
if (sigaction(SIGSEGV, &newAction, &oldAction_) < 0)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -38,7 +38,9 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "OSspecific.H"
|
#ifndef sigSegv_H
|
||||||
|
#define sigSegv_H
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -60,13 +62,15 @@ class sigSegv
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
static void sigSegvHandler(int);
|
//- Handler for caught signals
|
||||||
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
sigSegv();
|
sigSegv();
|
||||||
|
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
|
//- Activate SIGSEGV signal handler
|
||||||
void set(const bool verbose);
|
void set(const bool verbose);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,4 +89,8 @@ public:
|
|||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -83,6 +83,7 @@ SourceFiles
|
|||||||
#include "fileName.H"
|
#include "fileName.H"
|
||||||
#include "parRun.H"
|
#include "parRun.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
|
||||||
#include "sigFpe.H"
|
#include "sigFpe.H"
|
||||||
#include "sigInt.H"
|
#include "sigInt.H"
|
||||||
|
|||||||
Reference in New Issue
Block a user