| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/process/process_handle.h" | 5 #include "base/process/process_handle.h" |
| 6 | 6 |
| 7 #include <sys/sysctl.h> | 7 #include <sys/sysctl.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <sys/user.h> |
| 9 #include <unistd.h> | 10 #include <unistd.h> |
| 10 | 11 |
| 11 namespace base { | 12 namespace base { |
| 12 | 13 |
| 13 ProcessId GetParentProcessId(ProcessHandle process) { | 14 ProcessId GetParentProcessId(ProcessHandle process) { |
| 14 struct kinfo_proc info; | 15 struct kinfo_proc info; |
| 15 size_t length; | 16 size_t length; |
| 16 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process }; | 17 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process }; |
| 17 | 18 |
| 18 if (sysctl(mib, arraysize(mib), &info, &length, NULL, 0) < 0) | 19 if (sysctl(mib, arraysize(mib), &info, &length, NULL, 0) < 0) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 | 31 |
| 31 if (sysctl(mib, arraysize(mib), pathname, &length, NULL, 0) < 0 || | 32 if (sysctl(mib, arraysize(mib), pathname, &length, NULL, 0) < 0 || |
| 32 length == 0) { | 33 length == 0) { |
| 33 return FilePath(); | 34 return FilePath(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 return FilePath(std::string(pathname)); | 37 return FilePath(std::string(pathname)); |
| 37 } | 38 } |
| 38 | 39 |
| 39 } // namespace base | 40 } // namespace base |
| OLD | NEW |