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

systemd / systemd / 21014545754

14 Jan 2026 04:07PM UTC coverage: 72.704% (+0.02%) from 72.685%
21014545754

push

github

keszybz
mailmap: deduplicate some frequent contributors

310131 of 426565 relevant lines covered (72.7%)

1126978.63 hits per line

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

95.92
/src/shared/daemon-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "sd-daemon.h"
4

5
#include "alloc-util.h"
6
#include "daemon-util.h"
7
#include "fd-util.h"
8
#include "log.h"
9
#include "string-util.h"
10
#include "time-util.h"
11

12
static int notify_remove_fd_full(int log_level, const char *name) {
2,389✔
13
        int r;
2,389✔
14

15
        assert(name);
2,389✔
16

17
        r = sd_notifyf(/* unset_environment= */ false,
2,389✔
18
                       "FDSTOREREMOVE=1\n"
19
                       "FDNAME=%s", name);
20
        if (r < 0)
2,389✔
21
                return log_full_errno(
3✔
22
                                log_level, r,
23
                                "Failed to remove file descriptor \"%s\" from the store, ignoring: %m",
24
                                name);
25

26
        return 0;
27
}
28

29
int notify_remove_fd(const char *name) {
53✔
30
        return notify_remove_fd_full(LOG_DEBUG, name);
53✔
31
}
32

33
int notify_remove_fd_warn(const char *name) {
2,336✔
34
        return notify_remove_fd_full(LOG_WARNING, name);
2,336✔
35
}
36

37
int notify_remove_fd_warnf(const char *format, ...) {
1,189✔
38
        _cleanup_free_ char *p = NULL;
1,189✔
39
        va_list ap;
1,189✔
40
        int r;
1,189✔
41

42
        assert(format);
1,189✔
43

44
        va_start(ap, format);
1,189✔
45
        r = vasprintf(&p, format, ap);
1,189✔
46
        va_end(ap);
1,189✔
47
        if (r < 0)
1,189✔
48
                return log_oom();
×
49

50
        return notify_remove_fd_warn(p);
1,189✔
51
}
52

53
int close_and_notify_warn(int fd, const char *name) {
6✔
54
        if (name)
6✔
55
                (void) notify_remove_fd_warn(name);
6✔
56

57
        return safe_close(fd);
6✔
58
}
59

60
int notify_push_fd(int fd, const char *name) {
732✔
61
        _cleanup_free_ char *state = NULL;
732✔
62

63
        assert(fd >= 0);
732✔
64
        assert(name);
732✔
65

66
        state = strjoin("FDSTORE=1\n"
732✔
67
                        "FDNAME=", name);
68
        if (!state)
732✔
69
                return -ENOMEM;
70

71
        /* Remove existing fds with the same name in fdstore. */
72
        (void) notify_remove_fd_warn(name);
732✔
73

74
        return sd_pid_notify_with_fds(0, /* unset_environment= */ false, state, &fd, 1);
732✔
75
}
76

77
int notify_push_fdf(int fd, const char *format, ...) {
618✔
78
        _cleanup_free_ char *name = NULL;
618✔
79
        va_list ap;
618✔
80
        int r;
618✔
81

82
        assert(fd >= 0);
618✔
83
        assert(format);
618✔
84

85
        va_start(ap, format);
618✔
86
        r = vasprintf(&name, format, ap);
618✔
87
        va_end(ap);
618✔
88
        if (r < 0)
618✔
89
                return -ENOMEM;
90

91
        return notify_push_fd(fd, name);
618✔
92
}
93

94
int notify_reloading_full(const char *status) {
362✔
95
        int r;
362✔
96

97
        r = sd_notifyf(/* unset_environment= */ false,
362✔
98
                       "RELOADING=1\n"
99
                       "MONOTONIC_USEC=" USEC_FMT
100
                       "%s%s",
101
                       now(CLOCK_MONOTONIC),
102
                       status ? "\nSTATUS=" : "", strempty(status));
103
        if (r < 0)
362✔
104
                return log_debug_errno(r, "Failed to notify service manager for reloading status: %m");
×
105

106
        return 0;
107
}
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