1 #ifndef DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H
2 #define DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H
5 * Copyright (c) 2021 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.
22 #include <dali/public-api/signals/callback.h>
26 #include <dali/public-api/adaptor-framework/application.h>
28 #if !defined(_NSIG) && defined(NSIG)
39 * Class to listen to system signals and trigger an abort callback
42 * This class maintains a process wide singleton, as the signal(2) system
43 * call is process specific, not thread specific.
45 * Currently, this precludes having multiple DALi instances in the same process.
52 * @param[in] callback The function to call when abort signals occur
53 * @note The ownership of callback is passed onto this class.
55 AbortHandler(CallbackBase* callback);
63 * Add a signal you want to be handled by this abort handler.
64 * @param[in] signum The signal number (from signum.h)
65 * @return true if the signal handler was installed ok
67 bool AbortOnSignal(int signum);
71 * Signal handler - Called when signal is received.
72 * Stops the application.
74 static void SignalHandler(int signum);
77 * Default constructor - undefined
82 * Copy constructor - undefined
84 AbortHandler(const AbortHandler& rhs);
87 * Assignment operator - undefined
89 AbortHandler& operator=(const AbortHandler& rhs);
92 using SignalHandlerFuncPtr = void (*)(int);
94 // _NSIG comes from the signal.h linux system header, defining the number of signals.
95 SignalHandlerFuncPtr mSignalOldHandlers[_NSIG - 1];
96 unsigned long long mSignalMask;
98 CallbackBase* mCallback;
100 static AbortHandler* gInstance;
103 } // Namespace Adaptor
104 } // Namespace Internal
107 #endif // DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H