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 SANITIZERD_MONITOR_H 17 #define SANITIZERD_MONITOR_H 18 #include <poll.h> 19 #include <string> 20 21 #include "reporter.h" 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 26 typedef void (*SANITIZERD_NOTIFY_CALLBACK)(int32_t, const std::string&); 27 28 class SanitizerdMonitor { 29 public: 30 int Init(SANITIZERD_NOTIFY_CALLBACK pcb); 31 void Uninit(); 32 int RunMonitor(std::string *filename, int timeout); 33 34 private: 35 int ReadNotify(std::string *sfilename, int nfd); 36 struct pollfd* gUfds = nullptr; 37 int gNfds = 0; 38 SANITIZERD_NOTIFY_CALLBACK gCallback = nullptr; 39 int gAsanWd = -1; 40 }; 41 } 42 } 43 #endif // SANITIZERD_MONITOR_H 44 45