Module: xenomai-3
Branch: next
Commit: b10d2c429fe5ab98c56ebdd46b4e66599786c145
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b10d2c429fe5ab98c56ebdd46b4e66599786c145

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Dec 28 12:09:28 2015 +0100

copperplate/registry: handle bad stat reading in system/threads

---

 lib/copperplate/regd/fs-common.c |   25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/lib/copperplate/regd/fs-common.c b/lib/copperplate/regd/fs-common.c
index 99a2120..ef2e6da 100644
--- a/lib/copperplate/regd/fs-common.c
+++ b/lib/copperplate/regd/fs-common.c
@@ -119,12 +119,16 @@ int open_threads(struct fsobj *fsobj, void *priv)
                p->pid = thobj->pid;
                p->priority = threadobj_get_priority(thobj);
                p->policy = threadobj_get_policy(thobj);
-               threadobj_stat(thobj, &statbuf);
+               ret = threadobj_stat(thobj, &statbuf);
                threadobj_unlock(thobj);
-               p->status = statbuf.status;
-               p->cpu = statbuf.cpu;
-               p->timeout = statbuf.timeout;
-               p->schedlock = statbuf.schedlock;
+               if (ret)
+                       p->cpu = -1;
+               else {
+                       p->status = statbuf.status;
+                       p->cpu = statbuf.cpu;
+                       p->timeout = statbuf.timeout;
+                       p->schedlock = statbuf.schedlock;
+               }
                p++;
        }
 
@@ -142,8 +146,13 @@ int open_threads(struct fsobj *fsobj, void *priv)
                if (kill(p->pid, 0))
                        continue;
                snprintf(pbuf, sizeof(pbuf), "%3d", p->priority);
-               format_time(p->timeout, tbuf, sizeof(tbuf));
-               format_thread_status(p, sbuf, sizeof(sbuf));
+               if (p->cpu < 0) {
+                       strcpy(tbuf, "????");
+                       strcpy(sbuf, "??");
+               } else {
+                       format_time(p->timeout, tbuf, sizeof(tbuf));
+                       format_thread_status(p, sbuf, sizeof(sbuf));
+               }
                switch (p->policy) {
                case SCHED_FIFO:
                        sched_class = "fifo";
@@ -176,7 +185,7 @@ int open_threads(struct fsobj *fsobj, void *priv)
                        break;
                }
                len += fsobstack_grow_format(o,
-                                            "%3u  %-6d %-5s  %-8s %-8s  %-10s 
%s\n",
+                                            "%3d  %-6d %-5s  %-8s %-8s  %-10s 
%s\n",
                                             p->cpu, p->pid, sched_class, pbuf,
                                             tbuf, sbuf, p->name);
                p++;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to