1 /*
2  * Copyright (c) 2024 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 APPSPAWN_KICKDOG_H
17 #define APPSPAWN_KICKDOG_H
18 
19 #include <fcntl.h>
20 #include <stdio.h>
21 #include <signal.h>
22 #include "loop_event.h"
23 #include "appspawn_utils.h"
24 #include "appspawn_server.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #ifdef APPSPAWN_TEST    //macro for test
31 #define LINUX_APPSPAWN_WATCHDOG_FILE    "./TestDataFile.txt"
32 #define HM_APPSPAWN_WATCHDOG_FILE    "./TestDataFile.txt"
33 #else
34 #define LINUX_APPSPAWN_WATCHDOG_FILE    "/sys/kernel/hungtask/userlist"
35 #define HM_APPSPAWN_WATCHDOG_FILE    "/proc/sys/hguard/user_list"
36 #endif
37 
38 #define LINUX_APPSPAWN_WATCHDOG_ON    "on,30"
39 #define LINUX_APPSPAWN_WATCHDOG_KICK    "kick"
40 #define HM_APPSPAWN_WATCHDOG_ON    "on,10,appspawn"
41 #define HM_APPSPAWN_WATCHDOG_KICK    "kick,appspawn"
42 
43 #define APPSPAWN_WATCHDOG_KICKTIME    (10 * 1000)  //10s
44 
45 void AppSpawnKickDogStart(AppSpawnContent *content);
46 
47 #ifdef __cplusplus
48 }
49 #endif
50 #endif  //APPSPAWN_KICKDOG_H