2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 #include <sys/socket.h>
25 #include "socket-util.h"
27 /// Additional includes needed by elogind
28 #include "musl_missing.h"
30 int main(int argc, char *argv[]) {
32 static const union sockaddr_union sa = {
33 .un.sun_family = AF_UNIX,
34 .un.sun_path = "/run/systemd/cgroups-agent",
37 _cleanup_close_ int fd = -1;
42 log_error("Incorrect number of arguments.");
46 elogind_set_program_name(argv[0]);
47 log_set_target(LOG_TARGET_AUTO);
48 log_parse_environment();
51 fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
53 log_debug_errno(errno, "Failed to allocate socket: %m");
59 n = sendto(fd, argv[1], l, 0, &sa.sa, SOCKADDR_UN_LEN(sa.un));
61 log_debug_errno(errno, "Failed to send cgroups agent message: %m");
65 if ((size_t) n != l) {
66 log_debug("Datagram size mismatch");