* remove old files
* remove custom signal entries (Old svn revision: 1916)
This commit is contained in:
@@ -124,8 +124,6 @@ void load_config(void)
|
||||
win_width = xfce_rc_read_int_entry(rc_file, "win_width", 500);
|
||||
win_height = xfce_rc_read_int_entry(rc_file, "win_height", 400);
|
||||
|
||||
custom_signal_1 = xfce_rc_read_entry(rc_file, "custom_signal_1", "");
|
||||
custom_signal_0 = xfce_rc_read_entry(rc_file, "custom_signal_0", "Hello");
|
||||
xfce_rc_close(rc_file);
|
||||
}
|
||||
|
||||
@@ -145,9 +143,6 @@ void save_config(void)
|
||||
|
||||
xfce_rc_write_int_entry(rc_file, "win_width", win_width);
|
||||
xfce_rc_write_int_entry(rc_file, "win_height", win_height);
|
||||
|
||||
xfce_rc_write_entry(rc_file, "custom_signal_0", custom_signal_0);
|
||||
xfce_rc_write_entry(rc_file, "custom_signal_1", custom_signal_1);
|
||||
|
||||
xfce_rc_flush(rc_file);
|
||||
|
||||
|
||||
@@ -175,14 +175,6 @@ GtkWidget* create_taskpopup (void)
|
||||
gtk_widget_show (menu_item);
|
||||
gtk_container_add (GTK_CONTAINER (taskpopup), menu_item);
|
||||
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_task_menu), "KILL");
|
||||
|
||||
if(strcmp(custom_signal_0, "") != 0)
|
||||
{
|
||||
menu_item = gtk_menu_item_new_with_label (custom_signal_0);
|
||||
gtk_widget_show (menu_item);
|
||||
gtk_container_add (GTK_CONTAINER (taskpopup), menu_item);
|
||||
g_signal_connect ((gpointer) menu_item, "activate", G_CALLBACK (handle_task_menu), "OO");
|
||||
}
|
||||
|
||||
return taskpopup;
|
||||
}
|
||||
|
||||
154
src/linux.c
154
src/linux.c
@@ -1,154 +0,0 @@
|
||||
#include "linux.h"
|
||||
|
||||
struct task get_task_details(gint pid)
|
||||
{
|
||||
FILE *task_file;
|
||||
FILE *cmdline_file;
|
||||
gchar dummy[255];
|
||||
gchar buffer_status[256];
|
||||
struct task task;
|
||||
struct passwd *passwdp;
|
||||
struct stat status;
|
||||
gchar filename[255];
|
||||
gchar cmdline_filename[255];
|
||||
|
||||
sprintf(filename, "/proc/%i/stat", pid);
|
||||
sprintf(cmdline_filename, "/proc/%i/cmdline", pid);
|
||||
|
||||
stat(filename, &status);
|
||||
|
||||
//memset(&task, 0, sizeof(struct task));
|
||||
|
||||
task.pid = -1;
|
||||
task.checked = FALSE;
|
||||
|
||||
if((task_file = fopen(filename,"r")) != NULL)
|
||||
{
|
||||
while(fgets(buffer_status, sizeof(buffer_status), task_file) != NULL)
|
||||
{
|
||||
gint utime = 0;
|
||||
gint stime = 0;
|
||||
|
||||
sscanf(buffer_status, "%i (%s %1s %i %i %i %i %i %s %s %s %s %s %i %i %i %i %i %i %i %i %i %i %i %s %s %s %i %s %s %s %s %s %s %s %s %s %s %i %s %s",
|
||||
&task.pid, // processid
|
||||
&task.name, // processname
|
||||
&task.state, // processstate
|
||||
&task.ppid, // parentid
|
||||
&dummy, // processs groupid
|
||||
|
||||
&dummy, // session id
|
||||
&dummy, // tty id
|
||||
&dummy, // tpgid: The process group ID of the process running on tty of the process
|
||||
&dummy, // flags
|
||||
&dummy, // minflt minor faults the process has maid
|
||||
|
||||
&dummy, // cminflt
|
||||
&dummy, // majflt
|
||||
&dummy, // cmajflt
|
||||
&utime, // utime the number of jiffies that this process has scheduled in user mode
|
||||
&stime, // stime " kernel mode
|
||||
|
||||
&dummy, // cutime " waited for children in user
|
||||
&dummy, // cstime " kernel mode
|
||||
&dummy, // priority (nice value + fifteen)
|
||||
&dummy, // nice range from 19 to -19
|
||||
&dummy, // hardcoded 0
|
||||
|
||||
&dummy, // itrealvalue time in jiffies to next SIGALRM send to this process
|
||||
&dummy, // starttime jiffies the process startet after system boot
|
||||
&task.size, // vsize in bytes
|
||||
&task.rss, // rss
|
||||
&dummy, // rlim limit in bytes for rss
|
||||
|
||||
&dummy, // startcode
|
||||
&dummy, // endcode
|
||||
&dummy, // startstack
|
||||
&dummy, // kstkesp value of esp (stack pointer)
|
||||
&dummy, // kstkeip value of EIP (instruction pointer)
|
||||
|
||||
&dummy, // signal. bitmap of pending signals
|
||||
&dummy, // blocked: bitmap of blocked signals
|
||||
&dummy, // sigignore: bitmap of ignored signals
|
||||
&dummy, // sigcatch: bitmap of catched signals
|
||||
&dummy, // wchan
|
||||
|
||||
&dummy, // nswap
|
||||
&dummy, // cnswap
|
||||
&dummy, // exit_signal
|
||||
&dummy, // CPU number last executed on
|
||||
&dummy,
|
||||
|
||||
&dummy
|
||||
);
|
||||
task.time = stime + utime;
|
||||
task.old_time = task.time;
|
||||
task.time_percentage = 0;
|
||||
}
|
||||
task.uid = status.st_uid;
|
||||
passwdp = getpwuid(task.uid);
|
||||
if(passwdp != NULL && passwdp->pw_name != NULL)
|
||||
g_strlcpy(task.uname, passwdp->pw_name, sizeof task.uname);
|
||||
}
|
||||
|
||||
|
||||
if(task_file != NULL)
|
||||
fclose(task_file);
|
||||
|
||||
if((cmdline_file = fopen(cmdline_filename,"r")) != NULL)
|
||||
{
|
||||
gchar dummy[255];
|
||||
strcpy(&dummy, "");
|
||||
fscanf(cmdline_file, "%255s", &dummy);
|
||||
if(strcmp(dummy, "") != 0)
|
||||
{
|
||||
if(g_strrstr(dummy,"/") != NULL)
|
||||
g_strlcpy(task.name, g_strrstr(dummy,"/")+1, 255);
|
||||
else
|
||||
g_strlcpy(task.name, dummy, 255);
|
||||
|
||||
// workaround for cmd-line entries with leading "-"
|
||||
if(g_str_has_prefix(task.name, "-"))
|
||||
sscanf(task.name, "-%255s", task.name);
|
||||
}
|
||||
}
|
||||
|
||||
if(cmdline_file != NULL)
|
||||
fclose(cmdline_file);
|
||||
|
||||
if(g_str_has_suffix(task.name, ")"))
|
||||
*g_strrstr(task.name, ")") = '\0';
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
GArray *get_task_list()
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *dir_entry;
|
||||
GArray *task_list;
|
||||
|
||||
task_list = g_array_new (FALSE, FALSE, sizeof (struct task));
|
||||
|
||||
if((dir = opendir("/proc/")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error: couldn't load the /proc directory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gint count = 0;
|
||||
|
||||
while((dir_entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if(atoi(dir_entry->d_name) != 0)
|
||||
{
|
||||
struct task task = get_task_details(atoi(dir_entry->d_name));
|
||||
if(task.pid != -1)
|
||||
g_array_append_val(task_list, task);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
return task_list;
|
||||
}
|
||||
15
src/linux.h
15
src/linux.h
@@ -1,15 +0,0 @@
|
||||
#ifndef LINUX_H
|
||||
#define LINUX_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <dirent.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct task get_task_details(gint pid);
|
||||
GArray *get_task_list();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user