* some files renamed
* few small security changes (Old svn revision: 1915)
This commit is contained in:
25
aclocal.m4
vendored
25
aclocal.m4
vendored
@@ -592,6 +592,31 @@ AU_ALIAS([AC_PROG_INTLTOOL], [IT_PROG_INTLTOOL])
|
|||||||
# AC_DEFUN([AC_PROG_INTLTOOL], ...)
|
# AC_DEFUN([AC_PROG_INTLTOOL], ...)
|
||||||
|
|
||||||
|
|
||||||
|
# isc-posix.m4 serial 2 (gettext-0.11.2)
|
||||||
|
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
|
||||||
|
dnl This file is free software; the Free Software Foundation
|
||||||
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
dnl with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# This file is not needed with autoconf-2.53 and newer. Remove it in 2005.
|
||||||
|
|
||||||
|
# This test replaces the one in autoconf.
|
||||||
|
# Currently this macro should have the same name as the autoconf macro
|
||||||
|
# because gettext's gettext.m4 (distributed in the automake package)
|
||||||
|
# still uses it. Otherwise, the use in gettext.m4 makes autoheader
|
||||||
|
# give these diagnostics:
|
||||||
|
# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
|
||||||
|
# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
|
||||||
|
|
||||||
|
undefine([AC_ISC_POSIX])
|
||||||
|
|
||||||
|
AC_DEFUN([AC_ISC_POSIX],
|
||||||
|
[
|
||||||
|
dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
|
||||||
|
AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
|
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
|
||||||
|
|
||||||
# serial 48 AC_PROG_LIBTOOL
|
# serial 48 AC_PROG_LIBTOOL
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ xfce4_taskmanager_SOURCES = \
|
|||||||
callbacks.c callbacks.h \
|
callbacks.c callbacks.h \
|
||||||
functions.c functions.h \
|
functions.c functions.h \
|
||||||
interface.c interface.h \
|
interface.c interface.h \
|
||||||
linux.c linux.h \
|
xfce-taskmanager-linux.c xfce-taskmanager-linux.h \
|
||||||
types.h
|
types.h
|
||||||
|
|
||||||
xfce4_taskmanager_CFLAGS = \
|
xfce4_taskmanager_CFLAGS = \
|
||||||
|
|||||||
@@ -28,11 +28,17 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <libxfce4util/libxfce4util.h>
|
#include <libxfce4util/libxfce4util.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "linux.h"
|
#include "interface.h"
|
||||||
|
|
||||||
|
#ifdef LINUX
|
||||||
|
#include "xfce-taskmanager-linux.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PROC_DIR_1 "/compat/linux/proc"
|
#define PROC_DIR_1 "/compat/linux/proc"
|
||||||
#define PROC_DIR_2 "/emul/linux/proc"
|
#define PROC_DIR_2 "/emul/linux/proc"
|
||||||
|
|||||||
@@ -283,14 +283,14 @@ void fill_list_item(gint i, GtkTreeIter *iter)
|
|||||||
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_UNAME, uname, -1);
|
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_UNAME, uname, -1);
|
||||||
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_TIME, time, -1);
|
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_TIME, time, -1);
|
||||||
|
|
||||||
free(pid);
|
g_free(pid);
|
||||||
free(ppid);
|
g_free(ppid);
|
||||||
free(state);
|
g_free(state);
|
||||||
free(size);
|
g_free(size);
|
||||||
free(rss);
|
g_free(rss);
|
||||||
free(name);
|
g_free(name);
|
||||||
free(uname);
|
g_free(uname);
|
||||||
free(time);
|
g_free(time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,12 +355,12 @@ void remove_list_item(gint pid)
|
|||||||
|
|
||||||
if(pid == atoi(str_data))
|
if(pid == atoi(str_data))
|
||||||
{
|
{
|
||||||
free(str_data);
|
g_free(str_data);
|
||||||
gtk_tree_store_remove(GTK_TREE_STORE(list_store), &iter);
|
gtk_tree_store_remove(GTK_TREE_STORE(list_store), &iter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(str_data);
|
g_free(str_data);
|
||||||
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter);
|
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|||||||
152
src/xfce-taskmanager-linux.c
Executable file
152
src/xfce-taskmanager-linux.c
Executable file
@@ -0,0 +1,152 @@
|
|||||||
|
#include "xfce-taskmanager-linux.h"
|
||||||
|
|
||||||
|
struct task get_task_details(gint pid)
|
||||||
|
{
|
||||||
|
FILE *task_file;
|
||||||
|
FILE *cmdline_file;
|
||||||
|
gchar dummy[255];
|
||||||
|
gchar buffer_status[255];
|
||||||
|
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);
|
||||||
|
|
||||||
|
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 (%255s %1s %i %i %i %i %i %255s %255s %255s %255s %255s %i %i %i %i %i %i %i %i %i %i %i %255s %255s %255s %i %255s %255s %255s %255s %255s %255s %255s %255s %255s %255s %i %255s %255s",
|
||||||
|
&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;
|
||||||
|
}
|
||||||
17
src/xfce-taskmanager-linux.h
Executable file
17
src/xfce-taskmanager-linux.h
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef LINUX_H
|
||||||
|
#define LINUX_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
struct task get_task_details(gint pid);
|
||||||
|
GArray *get_task_list();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user