1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2010 Lennart Poettering
9 #include <sys/socket.h>
13 #include "socket-util.h"
15 /// Additional includes needed by elogind
16 #include "musl_missing.h"
18 int main(int argc, char *argv[]) {
20 static const union sockaddr_union sa = {
21 .un.sun_family = AF_UNIX,
22 .un.sun_path = "/run/systemd/cgroups-agent",
25 _cleanup_close_ int fd = -1;
30 log_error("Incorrect number of arguments.");
34 elogind_set_program_name(argv[0]);
35 log_set_target(LOG_TARGET_AUTO);
36 log_parse_environment();
39 fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
41 log_debug_errno(errno, "Failed to allocate socket: %m");
47 n = sendto(fd, argv[1], l, 0, &sa.sa, SOCKADDR_UN_LEN(sa.un));
49 log_debug_errno(errno, "Failed to send cgroups agent message: %m");
53 if ((size_t) n != l) {
54 log_debug("Datagram size mismatch");