commit: a29346b666decbba87f1d9cf56f7f72de485c343
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 4 11:52:13 2020 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct 4 11:52:13 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a29346b6
qlop: return sandbox piggybacking method of finding running merges
Because sandbox doesn't seem as dead as it was pronounced a while ago,
bring back support in qlop, since it is the easiest way to detect
running merges without any special privileges necessary.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
qlop.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/qlop.c b/qlop.c
index 316c9b0..dce46f2 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1197,6 +1197,8 @@ static array_t *probe_proc(array_t *atoms)
depend_atom *atom;
DECLARE_ARRAY(ret_atoms);
size_t i;
+ char *cmdline = NULL;
+ size_t cmdlinesize = 0;
/* /proc/<pid>/path/<[0-9]+link>
* /proc/<pid>/fd/<[0-9]+link> */
@@ -1218,6 +1220,33 @@ static array_t *probe_proc(array_t *atoms)
}
pid = d->d_name;
+
+ /* first try old-fashioned (good old) sandbox approach;
this
+ * one may not have a long life in Gentoo any more, but
for
+ * now it's still being used quite a lot, and the
advantage
+ * is that it doesn't require root access, for cmdline
can
+ * be read by anyone */
+ snprintf(npath, sizeof(npath), "/proc/%s/cmdline", pid);
+ if (eat_file(npath, &cmdline, &cmdlinesize)) {
+ if (cmdlinesize > 0 && cmdline[0] == '[' &&
+ (p = strchr(cmdline, ']')) !=
NULL &&
+ strncmp(p, "] sandbox",
sizeof("] sandbox") - 1) == 0)
+ {
+ *p = '\0';
+ atom = atom_explode(cmdline + 1);
+
+ if (atom != NULL) {
+ if (atom->CATEGORY == NULL ||
atom->P == NULL) {
+ atom_implode(atom);
+ } else {
+
xarraypush_ptr(ret_atoms, atom);
+ continue;
+ }
+ }
+ }
+ }
+
+ /* now try and see if Portage opened a build log
somewhere */
snprintf(npath, sizeof(npath), "/proc/%s/%s", pid,
subdir);
if ((linkslen = scandir(npath, &links, NULL, NULL)) >
0) {
for (li = 0; li < linkslen; li++) {