chiark / gitweb /
execute: allow configuration of SCHED_RESET_ON_FORK
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Feb 2010 11:50:04 +0000 (12:50 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Feb 2010 11:50:04 +0000 (12:50 +0100)
execute.c
execute.h
load-fragment.c

index ae32bcadac53f871a485729eb19b6b097a06323d..65a7fbba1eb45050bad90c03b0cd7e9b4565cc1e 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -347,7 +347,8 @@ int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds,
                         zero(param);
                         param.sched_priority = context->cpu_sched_priority;
 
                         zero(param);
                         param.sched_priority = context->cpu_sched_priority;
 
-                        if (sched_setscheduler(0, context->cpu_sched_policy, &param) < 0) {
+                        if (sched_setscheduler(0, context->cpu_sched_policy |
+                                               (context->cpu_sched_reset_on_fork ? SCHED_RESET_ON_FORK : 0), &param) < 0) {
                                 r = EXIT_SETSCHEDULER;
                                 goto fail;
                         }
                                 r = EXIT_SETSCHEDULER;
                                 goto fail;
                         }
@@ -563,9 +564,11 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
         if (c->cpu_sched_set)
                 fprintf(f,
                         "%sCPUSchedulingPolicy: %s\n"
         if (c->cpu_sched_set)
                 fprintf(f,
                         "%sCPUSchedulingPolicy: %s\n"
-                        "%sCPUSchedulingPriority: %i\n",
+                        "%sCPUSchedulingPriority: %i\n"
+                        "%sCPUSchedulingResetOnFork: %s\n",
                         prefix, sched_policy_to_string(c->cpu_sched_policy),
                         prefix, sched_policy_to_string(c->cpu_sched_policy),
-                        prefix, c->cpu_sched_priority);
+                        prefix, c->cpu_sched_priority,
+                        prefix, yes_no(c->cpu_sched_reset_on_fork));
 
         if (c->cpu_affinity_set) {
                 fprintf(f, "%sCPUAffinity:", prefix);
 
         if (c->cpu_affinity_set) {
                 fprintf(f, "%sCPUAffinity:", prefix);
index 09e4367974da05e945c811f78f326ac1b3ee90f5..4f700efd4623c3ddd9f1d7e5e895979d33944d3f 100644 (file)
--- a/execute.h
+++ b/execute.h
@@ -70,6 +70,8 @@ struct ExecContext {
         bool cpu_affinity_set:1;
         bool timer_slack_ns_set:1;
 
         bool cpu_affinity_set:1;
         bool timer_slack_ns_set:1;
 
+        bool cpu_sched_reset_on_fork;
+
         ExecInput input;
         ExecOutput output;
         int syslog_priority;
         ExecInput input;
         ExecOutput output;
         int syslog_priority;
index 4bb1ef0108d5371f76915e6c0c293befcfc029e9..c271ce5a5cc2f930f65fe1a5bff0ebf297fafb5a 100644 (file)
@@ -1024,6 +1024,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "IOSchedulingPriority",   config_parse_io_priority,     &(context),                                      section   }, \
                 { "CPUSchedulingPolicy",    config_parse_cpu_sched_policy,&(context),                                      section   }, \
                 { "CPUSchedulingPriority",  config_parse_cpu_sched_prio,  &(context),                                      section   }, \
                 { "IOSchedulingPriority",   config_parse_io_priority,     &(context),                                      section   }, \
                 { "CPUSchedulingPolicy",    config_parse_cpu_sched_policy,&(context),                                      section   }, \
                 { "CPUSchedulingPriority",  config_parse_cpu_sched_prio,  &(context),                                      section   }, \
+                { "CPUSchedulingResetOnFork", config_parse_bool,          &(context).cpu_sched_reset_on_fork,              section   }, \
                 { "CPUAffinity",            config_parse_cpu_affinity,    &(context),                                      section   }, \
                 { "UMask",                  config_parse_umask,           &(context).umask,                                section   }, \
                 { "Environment",            config_parse_strv,            &(context).environment,                          section   }, \
                 { "CPUAffinity",            config_parse_cpu_affinity,    &(context),                                      section   }, \
                 { "UMask",                  config_parse_umask,           &(context).umask,                                section   }, \
                 { "Environment",            config_parse_strv,            &(context).environment,                          section   }, \