diff --git a/frameworks/libhilog/base/hilog_base.c b/frameworks/libhilog/base/hilog_base.c index 6c26bf237fe1e5619c12979c5f47b8530c685d12..c482e9c9bf495559d40d5d3051ea9fcc297fb83e 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 e30f248b78ed08b86ec2bad2d6691a2cf11f4d06..24c664480cc9aec7c5279705e935456ae1969c4d 100644 --- a/frameworks/libhilog/hilog_printf.cpp +++ b/frameworks/libhilog/hilog_printf.cpp @@ -304,7 +304,9 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int header.type = type; header.level = level; #ifndef __RECV_MSG_WITH_UCRED_ -#ifndef __WINDOWS__ +#if defined(is_ohos) && is_ohos + header.pid = static_cast(getprocpid()); +#elif not defined(__WINDOWS__) header.pid = getpid(); #else header.pid = static_cast(GetCurrentProcessId()); diff --git a/services/hilogd/main.cpp b/services/hilogd/main.cpp index 2f2836de0ad7efb12f511887a97b5671fdf9101a..f966871b514f5e4a287be09a9c7ff66d7bcd99ee 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 56f88960e86bd3b3d43d57a20f3cef0a91f4d36b..382257bc128c2d4c44ff8aeb6f1dd3056d5efdc1 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;