]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/cgroups-agent/cgroups-agent.c
util-lib: split our string related calls from util.[ch] into its own file string...
[thirdparty/systemd.git] / src / cgroups-agent / cgroups-agent.c
CommitLineData
d6c9574f 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
8e274523
LP
2
3/***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
8e274523
LP
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 16 Lesser General Public License for more details.
8e274523 17
5430f7f2 18 You should have received a copy of the GNU Lesser General Public License
8e274523
LP
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
22f4096c
LP
22#include <stdlib.h>
23
d05f1cae 24#include "sd-bus.h"
07630cea 25
d05f1cae 26#include "bus-util.h"
07630cea 27#include "log.h"
8e274523
LP
28
29int main(int argc, char *argv[]) {
03976f7b 30 _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
d05f1cae 31 int r;
8e274523
LP
32
33 if (argc != 2) {
34 log_error("Incorrect number of arguments.");
d05f1cae 35 return EXIT_FAILURE;
8e274523
LP
36 }
37
4cfa2c99 38 log_set_target(LOG_TARGET_AUTO);
3c661fad 39 log_parse_environment();
2396fb04 40 log_open();
3c661fad 41
53c6a358
LP
42 /* We send this event to the private D-Bus socket and then the
43 * system instance will forward this to the system bus. We do
35b8ca3a 44 * this to avoid an activation loop when we start dbus when we
53c6a358
LP
45 * are called when the dbus service is shut down. */
46
266f3e26 47 r = bus_connect_system_systemd(&bus);
d05f1cae 48 if (r < 0) {
844de435
LP
49 /* If we couldn't connect we assume this was triggered
50 * while systemd got restarted/transitioned from
51 * initrd to the system, so let's ignore this */
da927ba9 52 log_debug_errno(r, "Failed to get D-Bus connection: %m");
d05f1cae 53 return EXIT_FAILURE;
8e274523
LP
54 }
55
d05f1cae
TG
56 r = sd_bus_emit_signal(bus,
57 "/org/freedesktop/systemd1/agent",
58 "org.freedesktop.systemd1.Agent",
59 "Released",
60 "s", argv[1]);
61 if (r < 0) {
da927ba9 62 log_debug_errno(r, "Failed to send signal message on private connection: %m");
d05f1cae 63 return EXIT_FAILURE;
51bc5d4b 64 }
8e274523 65
d05f1cae 66 return EXIT_SUCCESS;
8e274523 67}