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 /*
17 * SIG_BLOCK: Mask the signal according to the mask word provided by parameter set.
18 * And save the original signal mask to oldset
19 */
20 #define SIGCHAIN_TEST_SET_MASK(set, fun, signo, num) do{ \
21 int result = sigemptyset(&set); \
22 if (result != 0) { \
23 EXPECT_FALSE(fun, true); \
24 } \
25 for (int i = 0; i < num; i++) { \
26 result = sigaddset(&set, signo[i]); \
27 if (result != 0) { \
28 EXPECT_FALSE(fun, true); \
29 } \
30 } \
31 result = pthread_sigmask(SIG_BLOCK, &set, NULL); \
32 if (result != 0) { \
33 EXPECT_FALSE(fun, true); \
34 } \
35 } while (0)
36
37 #define SIGCHIAN_TEST_SIGNAL_NUM_1 1
38 #define SIGCHIAN_TEST_SIGNAL_NUM_2 2
39 #define SIGCHIAN_TEST_SIGNAL_NUM_3 3
40 #define SIGCHIAN_TEST_SIGNAL_NUM_4 4
41
42 #define SIGCHAIN_SIGNAL_37 37
43 #define SIGCHAIN_SIGNAL_43 43
44 #define SIGCHAIN_SIGNAL_45 45
45 #define SIGCHAIN_SIGNAL_56 56
46 #define SIGCHAIN_SIGNAL_64 64
47
get_sigchain_mask_enable()48 bool get_sigchain_mask_enable()
49 {
50 #ifdef OHOS_ENABLE_PARAMETER
51 static CachedHandle sigchain_procmask_handle = NULL;
52 if (sigchain_procmask_handle == NULL) {
53 sigchain_procmask_handle = CachedParameterCreate(param_name, "false");
54 }
55 char *param_value = CachedParameterGet(sigchain_procmask_handle);
56 if (param_value != NULL) {
57 if (strcmp(param_value, "true") == 0) {
58 return true;
59 }
60 }
61 #endif
62 return false;
63 }