From 4df4b1c3d693bdd1ea95f7d5382a90996fc98b99 Mon Sep 17 00:00:00 2001 From: liuyifei Date: Tue, 18 Jun 2024 09:09:22 +0000 Subject: [PATCH] change getpid() to getprocpid() Signed-off-by: liuyifei --- frameworks/libhilog/base/hilog_base.c | 2 +- frameworks/libhilog/hilog_printf.cpp | 2 +- services/hilogd/main.cpp | 2 +- test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/libhilog/base/hilog_base.c b/frameworks/libhilog/base/hilog_base.c index 6c26bf2..c482e9c 100644 --- a/frameworks/libhilog/base/hilog_base.c +++ b/frameworks/libhilog/base/hilog_base.c @@ -89,7 +89,7 @@ int HiLogBasePrintArgs( header.type = type; header.level = level; #ifndef __RECV_MSG_WITH_UCRED_ - header.pid = getpid(); + header.pid = getprocpid(); #endif header.tid = (uint32_t)(gettid()); header.domain = domain; diff --git a/frameworks/libhilog/hilog_printf.cpp b/frameworks/libhilog/hilog_printf.cpp index e30f248..39cbbfc 100644 --- a/frameworks/libhilog/hilog_printf.cpp +++ b/frameworks/libhilog/hilog_printf.cpp @@ -305,7 +305,7 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int header.level = level; #ifndef __RECV_MSG_WITH_UCRED_ #ifndef __WINDOWS__ - header.pid = getpid(); + header.pid = getprocpid(); #else header.pid = static_cast(GetCurrentProcessId()); #endif diff --git a/services/hilogd/main.cpp b/services/hilogd/main.cpp index 2f2836d..f966871 100644 --- a/services/hilogd/main.cpp +++ b/services/hilogd/main.cpp @@ -189,7 +189,7 @@ int HilogdEntry() } ffrt::submit([]() { - string myPid = to_string(getpid()); + string myPid = to_string(getprocpid()); (void)WriteStringToFile(myPid, SYSTEM_BG_STUNE); (void)WriteStringToFile(myPid, SYSTEM_BG_CPUSET); (void)WriteStringToFile(myPid, SYSTEM_BG_BLKIO); diff --git a/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp b/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp index 56f8896..382257b 100644 --- a/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp +++ b/test/fuzztest/hilogclient_fuzzer/hilogclient_fuzzer.cpp @@ -36,7 +36,7 @@ namespace OHOS { header.tv_sec = static_cast(ts.tv_sec); header.tv_nsec = static_cast(ts.tv_nsec); header.mono_sec = static_cast(tsMono.tv_sec); - header.pid = getpid(); + header.pid = getprocpid(); header.tid = static_cast(syscall(SYS_gettid)); header.type = LOG_CORE; header.level = LOG_INFO; -- Gitee