This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository evisum.

View the commit online.

commit d354ef51b37bf14953bfc1299557216849c74a15
Author: Alastair Poole <[email protected]>
AuthorDate: Sat Mar 28 05:44:33 2026 +0000

    process: Fix threads enumeration.
---
 src/bin/system/process.c | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/src/bin/system/process.c b/src/bin/system/process.c
index 94b6103..56b13b9 100644
--- a/src/bin/system/process.c
+++ b/src/bin/system/process.c
@@ -363,9 +363,9 @@ _net_stats_cache_get(void) {
 static Eina_Bool
 _stat(const char *path, Stat *st) {
     FILE *f;
-    char *p;
+    char *lparen, *rparen, *state;
     char line[4096];
-    int dummy, i, slen, len = 0;
+    int dummy, len = 0;
     static long tck = 0;
     static int64_t boot_time = 0;
 
@@ -377,22 +377,15 @@ _stat(const char *path, Stat *st) {
     if (!f) return 0;
 
     if (fgets(line, sizeof(line), f)) {
-        slen = strlen(line);
-        for (i = 0; i < slen; i++) {
-            Eina_Bool found = EINA_FALSE;
-            const char states[] = { 'D', 'I', 'R', 'X', 'T', 'S', 'Z' };
-            // Get the index of state value.
-            for (int j = 0; j < sizeof(states); j++) {
-                if (line[i] == states[j]) {
-                    found = EINA_TRUE;
-                    break;
-                }
-            }
-            if ((i < (slen - 1)) && (found) && (line[i + 1] == ' ')) break;
+        lparen = strchr(line, '(');
+        rparen = strrchr(line, ')');
+        if (!lparen || !rparen || (rparen <= lparen) || (rparen[1] != ' ') || !rparen[2]) {
+            fclose(f);
+            return 0;
         }
 
-        // Scan from index of state value.
-        len = sscanf(&line[i],
+        state = rparen + 2;
+        len = sscanf(state,
                      "%c %d %d %d %d %d %u %u %u %u %u %d %d %d"
                      " %d %d %d %u %u %lld %lu %u %u %u %u %u %u %u %d %d %d %d %u"
                      " %d %d %d %d %d %d %d %d %d",
@@ -401,15 +394,12 @@ _stat(const char *path, Stat *st) {
                      &st->start_time, &st->mem_virt, &st->mem_rss, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
                      &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &st->psr, &dummy, &dummy, &dummy,
                      &dummy, &dummy);
+
+        snprintf(st->name, sizeof(st->name), "%.*s", (int) (rparen - lparen - 1), lparen + 1);
     }
     fclose(f);
 
-    if (len != 42 || i == slen) return 0;
-
-    p = strchr(line, ' ') + 2;
-    if ((!p) || (i < 2)) return 0;
-    line[i - 2] = '\0';
-    snprintf(st->name, sizeof(st->name), "%s", p);
+    if (len != 42) return 0;
 
     if (!tck) tck = sysconf(_SC_CLK_TCK);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to