From: Lennart Poettering Date: Fri, 16 Oct 2020 15:16:02 +0000 (+0200) Subject: core: add comment explaining unit_kill_context() vs. unit_kill_common() a bit X-Git-Tag: v247-rc1~53^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8aff7ac4a7315ad7d4d1cf0c564885ba90d6818e;p=thirdparty%2Fsystemd.git core: add comment explaining unit_kill_context() vs. unit_kill_common() a bit --- diff --git a/src/core/unit.c b/src/core/unit.c index fd73ad2949f..052c11c00f4 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4331,17 +4331,21 @@ int unit_kill_common( int r = 0; bool killed = false; + /* This is the common implementation for explicit user-requested killing of unit processes, shared by + * various unit types. Do not confuse with unit_kill_context(), which is what we use when we want to + * stop a service ourselves. */ + if (IN_SET(who, KILL_MAIN, KILL_MAIN_FAIL)) { if (main_pid < 0) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_PROCESS, "%s units have no main processes", unit_type_to_string(u->type)); - else if (main_pid == 0) + if (main_pid == 0) return sd_bus_error_set_const(error, BUS_ERROR_NO_SUCH_PROCESS, "No main process to kill"); } if (IN_SET(who, KILL_CONTROL, KILL_CONTROL_FAIL)) { if (control_pid < 0) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_PROCESS, "%s units have no control processes", unit_type_to_string(u->type)); - else if (control_pid == 0) + if (control_pid == 0) return sd_bus_error_set_const(error, BUS_ERROR_NO_SUCH_PROCESS, "No control process to kill"); } @@ -4964,8 +4968,9 @@ int unit_kill_context( assert(u); assert(c); - /* Kill the processes belonging to this unit, in preparation for shutting the unit down. - * Returns > 0 if we killed something worth waiting for, 0 otherwise. */ + /* Kill the processes belonging to this unit, in preparation for shutting the unit down. Returns > 0 + * if we killed something worth waiting for, 0 otherwise. Do not confuse with unit_kill_common() + * which is used for user-requested killing of unit processes. */ if (c->kill_mode == KILL_NONE) return 0;