[Xfce4-commits] <xfce4-taskmanager:master> correctly implement set_priority/send_signal_to_pid()

Landry Breuil noreply at xfce.org
Thu May 13 20:10:03 CEST 2010


Updating branch refs/heads/master
         to 44dc437214888be0b21d25830976a76a88a4bd20 (commit)
       from 10247249ebb5aec6041876151c53085ce20c6192 (commit)

commit 44dc437214888be0b21d25830976a76a88a4bd20
Author: Landry Breuil <landry at rhaalovely.net>
Date:   Thu May 13 19:57:37 2010 +0200

    correctly implement set_priority/send_signal_to_pid()

 src/task-manager-bsd.c |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c
index 5c73d91..a7fd71f 100644
--- a/src/task-manager-bsd.c
+++ b/src/task-manager-bsd.c
@@ -203,27 +203,35 @@ gboolean send_signal_to_pid (guint task_id, gint signal)
 {
 	gint ret = 0;
 	if(task_id > 0 && signal != 0)
-	{
-		
 		ret = kill(task_id, signal);
-/*
-		if(ret != 0)
-			xfce_err(_("Couldn't send signal %d to the task with ID %d"), signal, task_id);
-*/	}
-	return ret;
+	return (ret == 0) ? TRUE : FALSE;
 }
 
 
 gboolean set_priority_to_pid (guint task_id, gint prio)
 {
-	if(task_id > 0)
+	gint res;
+	switch (prio)
 	{
-		gchar command[128] = "";
-		/* TODO : syscall */
-		g_snprintf(command, 128, "renice %d %d > /dev/null", prio, task_id);
-		
-		if(system(command) != 0)
-			;//xfce_err(_("Couldn't set priority %d to the task with ID %d"), prio, task_id);
+		case XTM_PRIORITY_VERY_LOW:
+			prio = 15;
+			break;
+		case XTM_PRIORITY_LOW:
+			prio = 5;
+			break;
+		case XTM_PRIORITY_NORMAL:
+			prio = 0;
+			break;
+		case XTM_PRIORITY_HIGH:
+			prio = -5;
+			break;
+		case XTM_PRIORITY_VERY_HIGH:
+			prio = -15;
+			break;
+		default:
+			return TRUE;
 	}
+	res = setpriority (PRIO_PROCESS, task_id, prio);
+	return (res == 0) ? TRUE : FALSE;
 }
 



More information about the Xfce4-commits mailing list