X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=execute.c;h=0374eaec5dae56ff2e339d225f1f2ec9078475cd;hb=ee2b489421ce8b47c08fb42c598c5af47043a9f9;hp=31e1bdc252b4bc8479a12f1037fc0eeef683f0e2;hpb=0bc824be78848cdf12f19aff4144666dc4114858;p=elogind.git diff --git a/execute.c b/execute.c index 31e1bdc25..0374eaec5 100644 --- a/execute.c +++ b/execute.c @@ -489,9 +489,16 @@ int exec_spawn(const ExecCommand *command, goto fail; } - if (setpgid(0, 0) < 0) { - r = EXIT_PGID; - goto fail; + if (context->new_session) { + if (setsid() < 0) { + r = EXIT_SETSID; + goto fail; + } + } else { + if (setpgid(0, 0) < 0) { + r = EXIT_PGID; + goto fail; + } } umask(context->umask); @@ -710,6 +717,12 @@ void exec_context_init(ExecContext *c) { c->cpu_sched_set = false; CPU_ZERO(&c->cpu_affinity); c->cpu_affinity_set = false; + c->timer_slack_ns = 0; + c->timer_slack_ns_set = false; + + c->cpu_sched_reset_on_fork = false; + c->non_blocking = false; + c->new_session = false; c->input = 0; c->output = 0; @@ -790,11 +803,13 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { "%sUMask: %04o\n" "%sWorkingDirectory: %s\n" "%sRootDirectory: %s\n" - "%sNonBlocking: %s\n", + "%sNonBlocking: %s\n" + "%sNewSession: %s\n", prefix, c->umask, prefix, c->working_directory ? c->working_directory : "/", prefix, c->root_directory ? c->root_directory : "/", - prefix, yes_no(c->non_blocking)); + prefix, yes_no(c->non_blocking), + prefix, yes_no(c->new_session)); if (c->environment) for (e = c->environment; *e; e++)