X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fexecute.c;h=dab485682b899daeac0bab8aeeb683a145e12dfc;hp=650c6c1436979328207aae765468e0f58a5bf64f;hb=1c0f62e37b0e775df7cb6121bc6ae64d1d885d3b;hpb=8d53b4534a5923721b5f1e9dd7e8f4a903d02d51 diff --git a/src/execute.c b/src/execute.c index 650c6c143..dab485682 100644 --- a/src/execute.c +++ b/src/execute.c @@ -770,8 +770,8 @@ static int setup_pam( * termination */ /* This string must fit in 10 chars (i.e. the length - * of "/sbin/init") */ - rename_process("sd(PAM)"); + * of "/sbin/init"), to look pretty in /bin/ps */ + rename_process("(sd-pam)"); /* Make sure we don't keep open the passed fds in this child. We assume that otherwise only those fds are @@ -919,6 +919,37 @@ finish: return r; } +static void rename_process_from_path(const char *path) { + char process_name[11]; + const char *p; + size_t l; + + /* This resulting string must fit in 10 chars (i.e. the length + * of "/sbin/init") to look pretty in /bin/ps */ + + p = file_name_from_path(path); + if (isempty(p)) { + rename_process("(...)"); + return; + } + + l = strlen(p); + if (l > 8) { + /* The end of the process name is usually more + * interesting, since the first bit might just be + * "systemd-" */ + p = p + l - 8; + l = 8; + } + + process_name[0] = '('; + memcpy(process_name+1, p, l); + process_name[1+l] = ')'; + process_name[1+l+1] = 0; + + rename_process(process_name); +} + int exec_spawn(ExecCommand *command, char **argv, const ExecContext *context, @@ -997,9 +1028,7 @@ int exec_spawn(ExecCommand *command, /* child */ - /* This string must fit in 10 chars (i.e. the length - * of "/sbin/init") */ - rename_process("sd(EXEC)"); + rename_process_from_path(command->path); /* We reset exactly these signals, since they are the * only ones we set to SIG_IGN in the main daemon. All @@ -1009,8 +1038,11 @@ int exec_spawn(ExecCommand *command, default_signals(SIGNALS_CRASH_HANDLER, SIGNALS_IGNORE, -1); - if (sigemptyset(&ss) < 0 || - sigprocmask(SIG_SETMASK, &ss, NULL) < 0) { + if (context->ignore_sigpipe) + ignore_signals(SIGPIPE, -1); + + assert_se(sigemptyset(&ss) == 0); + if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0) { err = -errno; r = EXIT_SIGNAL_MASK; goto fail_child; @@ -1218,7 +1250,7 @@ int exec_spawn(ExecCommand *command, if (cgroup_bondings && context->control_group_modify) { err = cgroup_bonding_set_group_access_list(cgroup_bondings, 0755, uid, gid); if (err >= 0) - err = cgroup_bonding_set_task_access_list(cgroup_bondings, 0644, uid, gid, context->control_group_persistant); + err = cgroup_bonding_set_task_access_list(cgroup_bondings, 0644, uid, gid, context->control_group_persistent); if (err < 0) { r = EXIT_CGROUP; goto fail_child; @@ -1228,8 +1260,8 @@ int exec_spawn(ExecCommand *command, } } - if (cgroup_bondings && !set_access && context->control_group_persistant >= 0) { - err = cgroup_bonding_set_task_access_list(cgroup_bondings, (mode_t) -1, (uid_t) -1, (uid_t) -1, context->control_group_persistant); + if (cgroup_bondings && !set_access && context->control_group_persistent >= 0) { + err = cgroup_bonding_set_task_access_list(cgroup_bondings, (mode_t) -1, (uid_t) -1, (uid_t) -1, context->control_group_persistent); if (err < 0) { r = EXIT_CGROUP; goto fail_child; @@ -1498,7 +1530,8 @@ void exec_context_init(ExecContext *c) { c->mount_flags = MS_SHARED; c->kill_signal = SIGTERM; c->send_sigkill = true; - c->control_group_persistant = -1; + c->control_group_persistent = -1; + c->ignore_sigpipe = true; } void exec_context_done(ExecContext *c) { @@ -1684,7 +1717,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { "%sNonBlocking: %s\n" "%sPrivateTmp: %s\n" "%sControlGroupModify: %s\n" - "%sControlGroupPersistant: %s\n" + "%sControlGroupPersistent: %s\n" "%sPrivateNetwork: %s\n", prefix, c->umask, prefix, c->working_directory ? c->working_directory : "/", @@ -1692,7 +1725,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { prefix, yes_no(c->non_blocking), prefix, yes_no(c->private_tmp), prefix, yes_no(c->control_group_modify), - prefix, yes_no(c->control_group_persistant), + prefix, yes_no(c->control_group_persistent), prefix, yes_no(c->private_network)); STRV_FOREACH(e, c->environment) @@ -1847,10 +1880,12 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { fprintf(f, "%sKillMode: %s\n" "%sKillSignal: SIG%s\n" - "%sSendSIGKILL: %s\n", + "%sSendSIGKILL: %s\n" + "%sIgnoreSIGPIPE: %s\n", prefix, kill_mode_to_string(c->kill_mode), prefix, signal_to_string(c->kill_signal), - prefix, yes_no(c->send_sigkill)); + prefix, yes_no(c->send_sigkill), + prefix, yes_no(c->ignore_sigpipe)); if (c->utmp_id) fprintf(f,