Move POSIX code to task-manager.c
The functions send_signal_to_pid() and set_priority_to_pid() are using POSIX functions and “should” be safe in task-manager.c. Still keep the enumeration as a bridge between virtual values and real values, there is no benefit removing them (wasting minutes) and it won't make the code look better (or worse). The functions have been removed from the Linux and BSD implementations.
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -329,58 +327,3 @@ pid_is_sleeping (guint pid)
|
||||
return (state[0] == 'T') ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
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