Update Solaris patch from Peter Tribble

Check for the lib kstat in the autoconf script.
Build with the correct file for Solaris in the automake script.
Fixed the xfce_err messages and switched to g_snprintf for the command strings.
Updated the TODO file.
This commit is contained in:
Mike Massonnet
2009-09-08 16:39:30 +02:00
parent 9e43755ce3
commit e05fff219f
8 changed files with 84 additions and 20 deletions

View File

@@ -1,5 +1,3 @@
# $Id$
INCLUDES = \
-I$(top_srcdir)/include \
-DG_LOG_DOMAIN=\"xfce4-taskmanager\" \
@@ -25,7 +23,7 @@ if OS_BSD_FAMILY
xfce4_taskmanager_SOURCES += taskmanager-bsd.c
endif
if OS_SOLARIS
xfce4_taskmanager_SOURCES += taskmanager-linux.c
xfce4_taskmanager_SOURCES += taskmanager-solaris.c
endif
if OS_LINUX
xfce4_taskmanager_SOURCES += taskmanager-linux.c

View File

@@ -58,13 +58,20 @@ gboolean refresh_task_list(void)
tmp->old_time_percentage = tmp->time_percentage;
tmp->time_percentage = (gdouble)(tmp->time - tmp->old_time) * (1.0/num_cpus);
#endif
#ifdef __sun
tmp->old_time = tmp->time;
tmp->time = new_tmp->time;
tmp->old_time_percentage = tmp->time_percentage;
tmp->time_percentage = (gdouble)(tmp->time - tmp->old_time) / (100.0*num_cpus);
#endif
if(
tmp->ppid != new_tmp->ppid ||
strcmp(tmp->state,new_tmp->state) ||
tmp->vsize != new_tmp->vsize ||
tmp->rss != new_tmp->rss ||
#ifdef __linux
#ifdef __linux || __sun
tmp->time_percentage != tmp->old_time_percentage ||
#endif
tmp->prio != new_tmp->prio

View File

@@ -238,6 +238,37 @@ GtkWidget *create_prio_submenu(void)
GtkWidget *prio_submenu = gtk_menu_new ();
GtkWidget *menu_item;
#ifdef __sun
menu_item = gtk_menu_item_new_with_label ("0");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.5);
gtk_widget_show (menu_item);
gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "0");
menu_item = gtk_menu_item_new_with_label ("-5");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.5);
gtk_widget_show (menu_item);
gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "-5");
menu_item = gtk_menu_item_new_with_label ("-10");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.5);
gtk_widget_show (menu_item);
gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "-10");
menu_item = gtk_menu_item_new_with_label ("-15");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.5);
gtk_widget_show (menu_item);
gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "-15");
menu_item = gtk_menu_item_new_with_label ("-20");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.5);
gtk_widget_show (menu_item);
gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "-20");
#else
menu_item = gtk_menu_item_new_with_label ("-10");
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (menu_item)->child), 1.0, 0.5);
gtk_widget_show (menu_item);
@@ -267,6 +298,7 @@ GtkWidget *create_prio_submenu(void)
gtk_widget_show (menu_item);
gtk_container_add (GTK_CONTAINER (prio_submenu), menu_item);
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_prio_menu), "10");
#endif
return prio_submenu;
}
@@ -451,7 +483,7 @@ void fill_list_item(gint i, GtkTreeIter *iter)
(gdouble)(task->rss)/1024/1024);
name = g_strdup_printf("%s", task->name);
uname = g_strdup_printf("%s", task->uname);
time = g_strdup_printf("%0d%%", (guint)task->time_percentage);
time = g_strdup_printf("%.0f%%", task->time_percentage);
prio = g_strdup_printf("%i", task->prio); /* my change */
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_NAME, name, -1);

View File

@@ -149,7 +149,7 @@ void send_signal_to_task(gint task_id, gint signal)
ret = kill(task_id, signal);
if(ret != 0)
xfce_err(_("Couldn't send signal to the task with ID %d"), signal, task_id);
xfce_err(_("Couldn't send signal %d to the task with ID %d"), signal, task_id);
}
}
@@ -159,7 +159,7 @@ void set_priority_to_task(gint task_id, gint prio)
if(task_id > 0)
{
gchar command[128] = "";
g_sprintf(command, "renice %d %d > /dev/null", prio, task_id);
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);

View File

@@ -371,7 +371,7 @@ void send_signal_to_task(gint task_id, gint signal)
ret = kill(task_id, signal);
if(ret != 0)
xfce_err(_("Couldn't send signal to the task with ID %d"), signal, task_id);
xfce_err(_("Couldn't send signal %d to the task with ID %d"), signal, task_id);
}
}
@@ -381,7 +381,7 @@ void set_priority_to_task(gint task_id, gint prio)
if(task_id > 0)
{
gchar command[128] = "";
g_sprintf(command, "renice %d %d > /dev/null", prio, task_id);
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);

View File

@@ -18,6 +18,19 @@
#include "taskmanager.h"
#include <dirent.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <kstat.h>
#include <fcntl.h>
#include <procfs.h>
#include <sys/procfs.h>
kstat_ctl_t *kc;
static void init_stats()
{
kc = kstat_open();
@@ -45,8 +58,9 @@ struct task get_task_details(gint pid)
sprintf(pstate, "%c", thisproc.pr_lwp.pr_sname);
g_strlcpy(task.state, pstate, 16);
task.ppid = (gint) thisproc.pr_ppid;
task.size = (gint) thisproc.pr_size;
task.rss = (gint) thisproc.pr_rssize;
task.prio = (gint) thisproc.pr_lwp.pr_pri;
task.vsize = (gint) thisproc.pr_size*1024;
task.rss = (gint) thisproc.pr_rssize*1024;
task.uid = (gint) thisproc.pr_uid;
passwdp = getpwuid(thisproc.pr_uid);
if(passwdp != NULL && passwdp->pw_name != NULL)
@@ -55,8 +69,8 @@ struct task get_task_details(gint pid)
* To get the appropriate precision we need to multiply up by 10000
* so that when we convert to a percentage we can represent 0.01%.
*/
task.time = 10000*thisproc.pr_time.tv_sec + thisproc.pr_time.tv_nsec/100000;
task.old_time = task.time;
task.time = 10000*thisproc.pr_time.tv_sec + thisproc.pr_time.tv_nsec/100000;
task.time_percentage = 0;
}
close(fd);
@@ -188,7 +202,7 @@ void send_signal_to_task(gint task_id, gint signal)
ret = kill(task_id, signal);
if(ret != 0)
xfce_err(_("Couldn't send signal to the task with ID %d"), signal, task_id);
xfce_err(_("Couldn't send signal %d to the task with ID %d"), signal, task_id);
}
}
@@ -198,8 +212,11 @@ void set_priority_to_task(gint task_id, gint prio)
if(task_id > 0)
{
gchar command[128] = "";
g_sprintf(command, "renice %d %d > /dev/null", prio, task_id);
g_snprintf(command, 128, "/usr/bin/priocntl -s -p %d -i pid %d > /dev/null", prio, task_id);
/*
* priocntl always returns 0, so this test is useless until
* priocntl gets fixed
*/
if(system(command) != 0)
xfce_err(_("Couldn't set priority %d to the task with ID %d"), prio, task_id);
}