diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-09-13 16:15:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-13 16:15:02 +0200 |
commit | de5ae832f26cc9b049ee28b61df816669a69e306 (patch) | |
tree | 0bb7d0810c66da5f28e9d364489b883f8233ca68 /src/core/service.c | |
parent | Merge pull request #13519 from yuwata/udev-fix-multi-match (diff) | |
parent | test: add more tests for "systemctl clean" (diff) | |
download | systemd-de5ae832f26cc9b049ee28b61df816669a69e306.tar.xz systemd-de5ae832f26cc9b049ee28b61df816669a69e306.zip |
Merge pull request #13439 from yuwata/core-support-systemctl-clean-more
core: support systemctl clean more
Diffstat (limited to 'src/core/service.c')
-rw-r--r-- | src/core/service.c | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/src/core/service.c b/src/core/service.c index 73b3c9c316..894b8af661 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -30,7 +30,6 @@ #include "parse-util.h" #include "path-util.h" #include "process-util.h" -#include "rm-rf.h" #include "serialize.h" #include "service.h" #include "signal-util.h" @@ -4246,7 +4245,6 @@ static int service_exit_status(Unit *u) { static int service_clean(Unit *u, ExecCleanMask mask) { _cleanup_strv_free_ char **l = NULL; Service *s = SERVICE(u); - pid_t pid; int r; assert(s); @@ -4271,36 +4269,16 @@ static int service_clean(Unit *u, ExecCleanMask mask) { if (r < 0) goto fail; - r = unit_fork_helper_process(UNIT(s), "(sd-rmrf)", &pid); - if (r < 0) - goto fail; - if (r == 0) { - int ret = EXIT_SUCCESS; - char **i; - - STRV_FOREACH(i, l) { - r = rm_rf(*i, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_MISSING_OK); - if (r < 0) { - log_error_errno(r, "Failed to remove '%s': %m", *i); - ret = EXIT_FAILURE; - } - } - - _exit(ret); - } - - r = unit_watch_pid(u, pid, true); + r = unit_fork_and_watch_rm_rf(u, l, &s->control_pid); if (r < 0) goto fail; - s->control_pid = pid; - service_set_state(s, SERVICE_CLEANING); return 0; fail: - log_unit_warning_errno(UNIT(s), r, "Failed to initiate cleaning: %m"); + log_unit_warning_errno(u, r, "Failed to initiate cleaning: %m"); s->clean_result = SERVICE_FAILURE_RESOURCES; s->timer_event_source = sd_event_source_unref(s->timer_event_source); return r; |