mirror of
https://git.freebsd.org/ports.git
synced 2025-05-05 16:07:38 -04:00
25 lines
704 B
C++
25 lines
704 B
C++
--- base/process/process_handle_freebsd.cc.orig 2023-11-03 10:09:45 UTC
|
|
+++ base/process/process_handle_freebsd.cc
|
|
@@ -3,6 +3,7 @@
|
|
// found in the LICENSE file.
|
|
|
|
#include "base/process/process_handle.h"
|
|
+#include "base/files/file_util.h"
|
|
|
|
#include <limits.h>
|
|
#include <stddef.h>
|
|
@@ -19,10 +20,13 @@ namespace base {
|
|
|
|
ProcessId GetParentProcessId(ProcessHandle process) {
|
|
struct kinfo_proc info;
|
|
- size_t length;
|
|
+ size_t length = sizeof(struct kinfo_proc);
|
|
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process };
|
|
|
|
if (sysctl(mib, std::size(mib), &info, &length, NULL, 0) < 0)
|
|
+ return -1;
|
|
+
|
|
+ if (length < sizeof(struct kinfo_proc))
|
|
return -1;
|
|
|
|
return info.ki_ppid;
|