[Xfce4-commits] [apps/xfce4-taskmanager] 20/20: Simplify the way process state is stored on FreeBSD (bug 14401)

noreply at xfce.org noreply at xfce.org
Wed May 30 22:00:34 CEST 2018


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

l   a   n   d   r   y       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-taskmanager.

commit 84e719796ec6223dd31107283918c08d22b268cf
Author: rim <rozhuk.im at gmail.com>
Date:   Wed May 30 21:59:02 2018 +0200

    Simplify the way process state is stored on FreeBSD (bug 14401)
---
 src/task-manager-freebsd.c | 51 +++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/src/task-manager-freebsd.c b/src/task-manager-freebsd.c
index 0cce230..c4d985f 100644
--- a/src/task-manager-freebsd.c
+++ b/src/task-manager-freebsd.c
@@ -27,7 +27,19 @@
 
 #include "task-manager.h"
 
-guint64
+static const gchar ki_stat2state[] = {
+	' ', /* - */
+	'R', /* SIDL */
+	'R', /* SRUN */
+	'S', /* SSLEEP */
+	'T', /* SSTOP */
+	'Z', /* SZOMB */
+	'W', /* SWAIT */
+	'L' /* SLOCK */
+};
+
+
+static guint64
 get_mem_by_bytes (const gchar *name)
 {
 	guint64 buf = 0;
@@ -170,36 +182,24 @@ get_task_details (struct kinfo_proc *kp, Task *task)
 	i = 0;
 	switch (kp->ki_stat)
 	{
-		case SSTOP:
-		task->state[i] = 'T';
-		break;
-
-		case SSLEEP:
-		if (kp->ki_tdflags & TDF_SINTR)
-			task->state[i] = kp->ki_slptime >= MAXSLP ? 'I' : 'S';
-		else
-			task->state[i] = 'D';
-		break;
-
-		case SRUN:
 		case SIDL:
-		task->state[i] = 'R';
-		break;
-
+		case SRUN:
+		case SSTOP:
+		case SZOMB:
 		case SWAIT:
-		task->state[i] = 'W';
-		break;
-
 		case SLOCK:
-		task->state[i] = 'L';
-		break;
+			task->state[i] = ki_stat2state[(size_t)kp->ki_stat];
+			break;
 
-		case SZOMB:
-		task->state[i] = 'Z';
-		break;
+		case SSLEEP:
+			if (kp->ki_tdflags & TDF_SINTR)
+				task->state[i] = kp->ki_slptime >= MAXSLP ? 'I' : 'S';
+			else
+				task->state[i] = 'D';
+			break;
 
 		default:
-		task->state[i] = '?';
+			task->state[i] = '?';
 	}
 	i++;
 	if (!(kp->ki_sflag & PS_INMEM))
@@ -222,7 +222,6 @@ get_task_details (struct kinfo_proc *kp, Task *task)
 		task->state[i++] = '+';
 	if (kp->ki_flag & P_JAILED)
 		task->state[i++] = 'J';
-	task->state[i] = '\0';
 
 	return TRUE;
 }

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


More information about the Xfce4-commits mailing list