1 #ifndef DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H
2 #define DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/public-api/signals/callback.h>
26 #include <dali/public-api/adaptor-framework/application.h>
28 #if !defined(_NSIG) && defined(NSIG)
40 * Class to listen to system signals and trigger an abort callback
43 * This class maintains a process wide singleton, as the signal(2) system
44 * call is process specific, not thread specific.
46 * Currently, this precludes having multiple DALi instances in the same process.
53 * @param[in] callback The function to call when abort signals occur
54 * @note The ownership of callback is passed onto this class.
56 AbortHandler( CallbackBase* callback );
64 * Add a signal you want to be handled by this abort handler.
65 * @param[in] signum The signal number (from signum.h)
66 * @return true if the signal handler was installed ok
68 bool AbortOnSignal( int signum );
72 * Signal handler - Called when signal is received.
73 * Stops the application.
75 static void SignalHandler( int signum );
78 * Default constructor - undefined
83 * Copy constructor - undefined
85 AbortHandler(const AbortHandler& rhs);
88 * Assignment operator - undefined
90 AbortHandler& operator=(const AbortHandler& rhs);
93 using SignalHandlerFuncPtr = void( * )( int );
95 // _NSIG comes from the signal.h linux system header, defining the number of signals.
96 SignalHandlerFuncPtr mSignalOldHandlers[_NSIG-1];
97 unsigned long long mSignalMask;
99 CallbackBase* mCallback;
101 static AbortHandler* gInstance;
104 } // Namespace Adaptor
105 } // Namespace Internal
108 #endif // DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H