Context menu for sending signals and setting priorities
Base signals and priorities are defined inside the task-manager.h file to be reused as general values inside the interface. The different OS implementations have to do the conversion from the enumeration to real values.
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -305,3 +307,64 @@ get_task_list (GArray *task_list)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
pid_is_sleeping (guint pid)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
send_signal_to_pid (guint pid, gint signal)
|
||||
{
|
||||
gint sig;
|
||||
gint res;
|
||||
switch (signal)
|
||||
{
|
||||
case XTM_SIGNAL_TERMINATE:
|
||||
sig = SIGTERM;
|
||||
break;
|
||||
case XTM_SIGNAL_STOP:
|
||||
sig = SIGSTOP;
|
||||
break;
|
||||
case XTM_SIGNAL_CONTINUE:
|
||||
sig = SIGCONT;
|
||||
break;
|
||||
case XTM_SIGNAL_KILL:
|
||||
sig = SIGKILL;
|
||||
break;
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
res = kill (pid, sig);
|
||||
return (res == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
set_priority_to_pid (guint pid, gint priority)
|
||||
{
|
||||
gint prio;
|
||||
gint res;
|
||||
switch (priority)
|
||||
{
|
||||
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, pid, prio);
|
||||
return (res == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user