1 |
commit: a29346b666decbba87f1d9cf56f7f72de485c343 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Oct 4 11:52:13 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Oct 4 11:52:13 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a29346b6 |
7 |
|
8 |
qlop: return sandbox piggybacking method of finding running merges |
9 |
|
10 |
Because sandbox doesn't seem as dead as it was pronounced a while ago, |
11 |
bring back support in qlop, since it is the easiest way to detect |
12 |
running merges without any special privileges necessary. |
13 |
|
14 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
15 |
|
16 |
qlop.c | 29 +++++++++++++++++++++++++++++ |
17 |
1 file changed, 29 insertions(+) |
18 |
|
19 |
diff --git a/qlop.c b/qlop.c |
20 |
index 316c9b0..dce46f2 100644 |
21 |
--- a/qlop.c |
22 |
+++ b/qlop.c |
23 |
@@ -1197,6 +1197,8 @@ static array_t *probe_proc(array_t *atoms) |
24 |
depend_atom *atom; |
25 |
DECLARE_ARRAY(ret_atoms); |
26 |
size_t i; |
27 |
+ char *cmdline = NULL; |
28 |
+ size_t cmdlinesize = 0; |
29 |
|
30 |
/* /proc/<pid>/path/<[0-9]+link> |
31 |
* /proc/<pid>/fd/<[0-9]+link> */ |
32 |
@@ -1218,6 +1220,33 @@ static array_t *probe_proc(array_t *atoms) |
33 |
} |
34 |
|
35 |
pid = d->d_name; |
36 |
+ |
37 |
+ /* first try old-fashioned (good old) sandbox approach; this |
38 |
+ * one may not have a long life in Gentoo any more, but for |
39 |
+ * now it's still being used quite a lot, and the advantage |
40 |
+ * is that it doesn't require root access, for cmdline can |
41 |
+ * be read by anyone */ |
42 |
+ snprintf(npath, sizeof(npath), "/proc/%s/cmdline", pid); |
43 |
+ if (eat_file(npath, &cmdline, &cmdlinesize)) { |
44 |
+ if (cmdlinesize > 0 && cmdline[0] == '[' && |
45 |
+ (p = strchr(cmdline, ']')) != NULL && |
46 |
+ strncmp(p, "] sandbox", sizeof("] sandbox") - 1) == 0) |
47 |
+ { |
48 |
+ *p = '\0'; |
49 |
+ atom = atom_explode(cmdline + 1); |
50 |
+ |
51 |
+ if (atom != NULL) { |
52 |
+ if (atom->CATEGORY == NULL || atom->P == NULL) { |
53 |
+ atom_implode(atom); |
54 |
+ } else { |
55 |
+ xarraypush_ptr(ret_atoms, atom); |
56 |
+ continue; |
57 |
+ } |
58 |
+ } |
59 |
+ } |
60 |
+ } |
61 |
+ |
62 |
+ /* now try and see if Portage opened a build log somewhere */ |
63 |
snprintf(npath, sizeof(npath), "/proc/%s/%s", pid, subdir); |
64 |
if ((linkslen = scandir(npath, &links, NULL, NULL)) > 0) { |
65 |
for (li = 0; li < linkslen; li++) { |