• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 16280725298

14 Jul 2025 08:16PM UTC coverage: 72.166% (-0.006%) from 72.172%
16280725298

push

github

web-flow
Two fixlets for coverage test (#38183)

302135 of 418667 relevant lines covered (72.17%)

773261.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.93
/src/systemctl/systemctl-kill.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "sd-bus.h"
4

5
#include "bus-error.h"
6
#include "bus-locator.h"
7
#include "bus-wait-for-units.h"
8
#include "errno-util.h"
9
#include "log.h"
10
#include "string-util.h"
11
#include "strv.h"
12
#include "systemctl.h"
13
#include "systemctl-kill.h"
14
#include "systemctl-util.h"
15

16
int verb_kill(int argc, char *argv[], void *userdata) {
43✔
17
        _cleanup_(bus_wait_for_units_freep) BusWaitForUnits *w = NULL;
43✔
18
        _cleanup_strv_free_ char **names = NULL;
43✔
19
        const char *kill_whom;
43✔
20
        sd_bus *bus;
43✔
21
        int r, q;
43✔
22

23
        if (arg_kill_subgroup && arg_kill_value_set)
43✔
24
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--kill-subgroup= and --kill-value= may not be combined.");
×
25

26
        r = acquire_bus(BUS_MANAGER, &bus);
43✔
27
        if (r < 0)
43✔
28
                return r;
29

30
        if (arg_wait) {
43✔
31
                r = bus_wait_for_units_new(bus, &w);
1✔
32
                if (r < 0)
1✔
33
                        return log_error_errno(r, "Failed to allocate unit watch context: %m");
×
34
        }
35

36
        polkit_agent_open_maybe();
43✔
37

38
        kill_whom = arg_kill_whom ?: arg_kill_subgroup ? "cgroup" : "all";
43✔
39

40
        /* --fail was specified */
41
        if (streq(arg_job_mode(), "fail"))
86✔
42
                kill_whom = strjoina(kill_whom, "-fail");
×
43

44
        r = expand_unit_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
43✔
45
        if (r < 0)
43✔
46
                return log_error_errno(r, "Failed to expand names: %m");
×
47

48
        STRV_FOREACH(name, names) {
86✔
49
                _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
37✔
50

51
                if (arg_kill_value_set)
43✔
52
                        q = bus_call_method(
6✔
53
                                        bus,
54
                                        bus_systemd_mgr,
55
                                        "QueueSignalUnit",
56
                                        &error,
57
                                        NULL,
58
                                        "ssii", *name, kill_whom, arg_signal, arg_kill_value);
59
                else if (arg_kill_subgroup)
37✔
60
                        q = bus_call_method(
11✔
61
                                        bus,
62
                                        bus_systemd_mgr,
63
                                        "KillUnitSubgroup",
64
                                        &error,
65
                                        NULL,
66
                                        "sssi", *name, kill_whom, arg_kill_subgroup, arg_signal);
67
                else
68
                        q = bus_call_method(
26✔
69
                                        bus,
70
                                        bus_systemd_mgr,
71
                                        "KillUnit",
72
                                        &error,
73
                                        NULL,
74
                                        "ssi", *name, kill_whom, arg_signal);
75
                if (q < 0) {
43✔
76
                        RET_GATHER(r, log_error_errno(q, "Failed to kill unit %s: %s", *name, bus_error_message(&error, q)));
6✔
77
                        continue;
6✔
78
                }
79

80
                if (w) {
37✔
81
                        q = bus_wait_for_units_add_unit(w, *name, BUS_WAIT_FOR_INACTIVE|BUS_WAIT_NO_JOB, NULL, NULL);
1✔
82
                        if (q < 0)
1✔
83
                                RET_GATHER(r, log_error_errno(q, "Failed to watch unit %s: %m", *name));
×
84
                }
85
        }
86

87
        if (w) {
43✔
88
                q = bus_wait_for_units_run(w);
1✔
89
                if (q < 0)
1✔
90
                        return log_error_errno(q, "Failed to wait for units: %m");
×
91
                if (q == BUS_WAIT_FAILURE)
1✔
92
                        RET_GATHER(r, -EIO);
×
93
        }
94

95
        return r;
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc