| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/process/internal_linux.h" | 8 #include "base/process/internal_linux.h" |
| 9 #if defined(OS_AIX) |
| 10 #include "base/process/internal_aix.h" |
| 11 #endif |
| 9 | 12 |
| 10 namespace base { | 13 namespace base { |
| 11 | 14 |
| 12 ProcessId GetParentProcessId(ProcessHandle process) { | 15 ProcessId GetParentProcessId(ProcessHandle process) { |
| 13 ProcessId pid = | 16 ProcessId pid = |
| 17 #if defined(OS_AIX) |
| 18 internalAIX::ReadProcStatsAndGetFieldAsInt64(process, |
| 19 internalAIX::VM_PPID); |
| 20 #else |
| 14 internal::ReadProcStatsAndGetFieldAsInt64(process, internal::VM_PPID); | 21 internal::ReadProcStatsAndGetFieldAsInt64(process, internal::VM_PPID); |
| 22 #endif |
| 15 if (pid) | 23 if (pid) |
| 16 return pid; | 24 return pid; |
| 17 return -1; | 25 return -1; |
| 18 } | 26 } |
| 19 | 27 |
| 20 FilePath GetProcessExecutablePath(ProcessHandle process) { | 28 FilePath GetProcessExecutablePath(ProcessHandle process) { |
| 21 FilePath stat_file = internal::GetProcPidDir(process).Append("exe"); | 29 FilePath stat_file = internal::GetProcPidDir(process).Append("exe"); |
| 22 FilePath exe_name; | 30 FilePath exe_name; |
| 23 if (!ReadSymbolicLink(stat_file, &exe_name)) { | 31 if (!ReadSymbolicLink(stat_file, &exe_name)) { |
| 24 // No such process. Happens frequently in e.g. TerminateAllChromeProcesses | 32 // No such process. Happens frequently in e.g. TerminateAllChromeProcesses |
| 25 return FilePath(); | 33 return FilePath(); |
| 26 } | 34 } |
| 27 return exe_name; | 35 return exe_name; |
| 28 } | 36 } |
| 29 | 37 |
| 30 } // namespace base | 38 } // namespace base |
| OLD | NEW |