Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: base/process_util_freebsd.cc

Issue 19064002: Split ProcessHandle and its related routines into base/process/process_handle.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/process_util.h ('k') | base/process_util_ios.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/process_util.h"
6
7 #include <ctype.h>
8 #include <dirent.h>
9 #include <dlfcn.h>
10 #include <errno.h>
11 #include <fcntl.h>
12 #include <sys/sysctl.h>
13 #include <sys/time.h>
14 #include <sys/types.h>
15 #include <sys/user.h>
16 #include <sys/wait.h>
17 #include <time.h>
18 #include <unistd.h>
19
20 #include "base/logging.h"
21 #include "base/string_tokenizer.h"
22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h"
24 #include "base/strings/string_util.h"
25 #include "base/sys_info.h"
26
27 namespace base {
28
29 ProcessId GetParentProcessId(ProcessHandle process) {
30 struct kinfo_proc info;
31 size_t length;
32 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process };
33
34 if (sysctl(mib, arraysize(mib), &info, &length, NULL, 0) < 0)
35 return -1;
36
37 return info.ki_ppid;
38 }
39
40 FilePath GetProcessExecutablePath(ProcessHandle process) {
41 char pathname[PATH_MAX];
42 size_t length;
43 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, process };
44
45 length = sizeof(pathname);
46
47 if (sysctl(mib, arraysize(mib), pathname, &length, NULL, 0) < 0 ||
48 length == 0) {
49 return FilePath();
50 }
51
52 return FilePath(std::string(pathname));
53 }
54
55 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | base/process_util_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698