]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/cgroups-agent/cgroups-agent.c
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 int main(int argc
, char *argv
[]) {
29 static const union sockaddr_union sa
= {
30 .un
.sun_family
= AF_UNIX
,
31 .un
.sun_path
= "/run/systemd/cgroups-agent",
34 _cleanup_close_
int fd
= -1;
39 log_error("Incorrect number of arguments.");
43 log_set_target(LOG_TARGET_AUTO
);
44 log_parse_environment();
47 fd
= socket(AF_UNIX
, SOCK_DGRAM
|SOCK_CLOEXEC
, 0);
49 log_debug_errno(errno
, "Failed to allocate socket: %m");
55 n
= sendto(fd
, argv
[1], l
, 0, &sa
.sa
, offsetof(struct sockaddr_un
, sun_path
) + strlen(sa
.un
.sun_path
));
57 log_debug_errno(errno
, "Failed to send cgroups agent message: %m");
61 if ((size_t) n
!= l
) {
62 log_debug("Datagram size mismatch");