Mercurial > minori
annotate dep/animone/src/fd/xnu.cc @ 366:886f66775f31
animone: add preliminary AT-SPI stuff
anime_list: finish the regular singular right click menu
author | Paper <paper@tflc.us> |
---|---|
date | Sun, 17 Nov 2024 19:56:01 -0500 |
parents | f81bed4e04ac |
children |
rev | line source |
---|---|
310
a4257370de16
dep/animone: prepare for v1.0 release; it should be ready by now
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
1 /* |
a4257370de16
dep/animone: prepare for v1.0 release; it should be ready by now
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
2 * fd/xnu.cc: support for macOS's kernel |
a4257370de16
dep/animone: prepare for v1.0 release; it should be ready by now
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
3 * |
a4257370de16
dep/animone: prepare for v1.0 release; it should be ready by now
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
4 * this used to have all sorts of hacks for getting the process name, |
a4257370de16
dep/animone: prepare for v1.0 release; it should be ready by now
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
5 * but ultimately I just decided that it's better to just parse the |
a4257370de16
dep/animone: prepare for v1.0 release; it should be ready by now
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
6 * PID path from xnu, which should work perfectly fine. |
a4257370de16
dep/animone: prepare for v1.0 release; it should be ready by now
Paper <paper@paper.us.eu.org>
parents:
301
diff
changeset
|
7 */ |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
8 #include "animone/fd/xnu.h" |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
9 #include "animone.h" |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
10 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
11 #include <cassert> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
12 #include <memory> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
13 #include <string> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
14 #include <unordered_map> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
15 #include <vector> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
16 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
17 #include <fcntl.h> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
18 #include <libproc.h> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
19 #include <sys/sysctl.h> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
20 #include <sys/types.h> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
21 #include <sys/user.h> |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
22 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
23 /* you may be asking: WTF is FWRITE? |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
24 * well, from bsd/sys/fcntl.h in the XNU kernel: |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
25 * |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
26 * Kernel encoding of open mode; separate read and write bits that are |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
27 * independently testable: 1 greater than [O_RDONLY and O_WRONLY]. |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
28 * |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
29 * It's just how the kernel defines write mode. |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
30 */ |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
31 #ifndef FWRITE |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
32 #define FWRITE 0x0002 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
33 #endif |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
34 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
35 namespace animone::internal::xnu { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
36 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
37 bool EnumerateOpenProcesses(process_proc_t process_proc) { |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
38 /* pre-allocate 256 pids */ |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
39 std::vector<pid_t> pids(256); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
40 int returned_size_bytes = 0; |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
41 |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
42 for (;;) { |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
43 returned_size_bytes = proc_listpids(PROC_ALL_PIDS, 0, pids.data(), pids.size() * sizeof(pid_t)); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
44 if (returned_size_bytes <= 0) /* probably an error ? */ |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
45 return false; |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
46 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
47 /* break out of the loop if we have everything */ |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
48 if ((pids.size() * sizeof(pid_t)) > returned_size_bytes) |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
49 break; |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
50 |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
51 pids.resize(pids.size() * 2); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
52 } |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
53 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
54 pids.resize(returned_size_bytes); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
55 |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
56 for (const auto& pid : pids) { |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
57 std::string result; |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
58 GetProcessName(pid, result); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
59 if (!process_proc({.platform = ExecutablePlatform::Xnu, .pid = pid, .comm = result})) |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
60 return false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
61 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
62 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
63 return true; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
64 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
65 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
66 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
67 if (!open_file_proc) |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
68 return false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
69 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
70 for (const auto& pid : pids) { |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
71 /* most processes probably don't even have that many files opened! */ |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
72 std::vector<struct proc_fdinfo> fds(4); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
73 int returned_size_bytes = 0; |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
74 |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
75 for (;;) { |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
76 returned_size_bytes = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, fds.data(), fds.size()); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
77 if (returned_size_bytes <= 0) /* probably an error ? */ |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
78 return false; |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
79 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
80 /* break out of the loop if we have everything */ |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
81 if ((fds.size() * sizeof(struct proc_fdinfo)) > returned_size_bytes) |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
82 break; |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
83 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
84 fds.resize(fds.size() * 2); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
85 } |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
86 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
87 fds.resize(returned_size_bytes / sizeof(struct proc_fdinfo)); |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
88 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
89 for (const auto& fd : fds) { |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
90 if (fd.proc_fdtype != PROX_FDTYPE_VNODE) |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
91 continue; |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
92 |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
93 struct vnode_fdinfowithpath vnodeInfo; |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
94 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
95 int sz = proc_pidfdinfo(pid, fd.proc_fd, PROC_PIDFDVNODEPATHINFO, &vnodeInfo, |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
96 PROC_PIDFDVNODEPATHINFO_SIZE); |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
97 if (sz != PROC_PIDFDVNODEPATHINFO_SIZE) |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
98 return false; |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
99 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
100 /* why would a media player open a file in write mode? */ |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
101 if (vnodeInfo.pfi.fi_openflags & FWRITE) |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
102 continue; |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
103 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
104 if (!open_file_proc({pid, vnodeInfo.pvip.vip_path})) |
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
105 return false; |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
106 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
107 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
108 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
109 return true; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
110 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
111 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
112 static bool GetProcessNameFromProcPidPath(pid_t pid, std::string& result) { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
113 result.assign(PROC_PIDPATHINFO_MAXSIZE, '\0'); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
114 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
115 int ret = proc_pidpath(pid, result.data(), result.size()); |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
116 if (ret <= 0) |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
117 return false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
118 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
119 /* find the last slash, if there's none, we're done here */ |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
120 size_t last_slash = result.rfind('/'); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
121 if (last_slash == std::string::npos) |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
122 return true; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
123 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
124 result.erase(0, last_slash + 1); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
125 return true; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
126 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
127 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
128 static bool GetProcessNameFromProcName(pid_t pid, std::string& result) { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
129 result.assign(2 * MAXCOMLEN, '\0'); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
130 |
365
f81bed4e04ac
*: megacommit that probably breaks things
Paper <paper@paper.us.eu.org>
parents:
337
diff
changeset
|
131 int size = proc_name(pid, result.data(), result.length()); |
301
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
132 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
133 /* if size is MAXCOMLEN or 2 * MAXCOMLEN, assume |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
134 * this method won't work and our result is truncated */ |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
135 if (size <= 0 || size == MAXCOMLEN || size == 2 * MAXCOMLEN) |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
136 return false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
137 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
138 result.resize(size); |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
139 return true; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
140 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
141 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
142 bool GetProcessName(pid_t pid, std::string& result) { |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
143 if (GetProcessNameFromProcName(pid, result)) |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
144 return true; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
145 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
146 if (GetProcessNameFromProcPidPath(pid, result)) |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
147 return true; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
148 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
149 return false; |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
150 } |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
151 |
b1f625b0227c
*: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents:
299
diff
changeset
|
152 } // namespace animone::internal::xnu |