• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _SIGCHAIN_H
17 #define _SIGCHAIN_H
18 
19 #ifndef _GNU_SOURCE
20 #define _GNU_SOURCE
21 #endif
22 #include <signal.h>
23 #include <stdint.h>
24 #include <stdbool.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 static const int SIGCHAIN_ALLOW_NORETURN = 0x1UL;
31 
32 /* The action of the sigchain. */
33 struct signal_chain_action {
34     bool (*sca_sigaction)(int, siginfo_t*, void*);
35     sigset_t sca_mask;
36     int sca_flags;
37 };
38 
39 /* Mark the signal to the sigchain, add the special handler to the sigchain. */
40 void add_special_signal_handler(int signo, struct signal_chain_action* sa);
41 /* Add the special handler at the last of sigchain chains */
42 void add_special_handler_at_last(int signo, struct signal_chain_action* sa);
43 /* Remove the special the handler from the sigchain. */
44 void remove_special_signal_handler(int signo, bool (*fn)(int, siginfo_t*, void*));
45 /* Remove all special the handler from the sigchain */
46 void remove_all_special_handler(int signo);
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif