summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 62ae599..7507ae5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sched.h>
#include <limits.h>
struct ct_general_state st;
@@ -296,6 +297,23 @@ int main(int argc, char *argv[])
close(ret);
/*
+ * Setting process priority and scheduler
+ */
+ nice(CONFIG(nice));
+
+ if (CONFIG(sched).type != SCHED_OTHER) {
+ struct sched_param schedparam = {
+ .sched_priority = CONFIG(sched).prio,
+ };
+
+ ret = sched_setscheduler(0, CONFIG(sched).type, &schedparam);
+ if (ret == -1) {
+ perror("sched");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /*
* initialization process
*/
@@ -309,7 +327,6 @@ int main(int argc, char *argv[])
chdir("/");
close(STDIN_FILENO);
- nice(CONFIG(nice));
/* Daemonize conntrackd */
if (type == DAEMON) {