mac: silence proc_pidpath warning

This commit is contained in:
Peter Steinberger
2025-12-10 01:43:34 +01:00
parent 08f8f58971
commit 5bbc7c8ba2

View File

@@ -243,7 +243,9 @@ actor PortGuardian {
var buffer = [CChar](repeating: 0, count: Int(PATH_MAX))
let length = proc_pidpath(pid, &buffer, UInt32(buffer.count))
guard length > 0 else { return nil }
return String(cString: buffer)
// Drop trailing null and decode as UTF-8.
let trimmed = buffer.prefix { $0 != 0 }
return String(decoding: trimmed.map { UInt8(bitPattern: $0) }, as: UTF8.self)
#else
return nil
#endif