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:
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
/* for getpwuid() */
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
@@ -26,9 +27,6 @@
|
||||
#include <sys/sysctl.h>
|
||||
/* for swapctl() */
|
||||
#include <sys/swap.h>
|
||||
/* for kill() */
|
||||
#include <signal.h>
|
||||
#include <err.h>
|
||||
/* for strlcpy() */
|
||||
#include <string.h>
|
||||
/* for getpagesize() */
|
||||
@@ -195,39 +193,3 @@ gboolean get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean send_signal_to_pid (guint task_id, gint signal)
|
||||
{
|
||||
gint ret = 0;
|
||||
if(task_id > 0 && signal != 0)
|
||||
ret = kill(task_id, signal);
|
||||
return (ret == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
gboolean set_priority_to_pid (guint task_id, gint prio)
|
||||
{
|
||||
gint res;
|
||||
switch (prio)
|
||||
{
|
||||
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, task_id, prio);
|
||||
return (res == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user