]> git.proxmox.com Git - systemd.git/blame - src/cgroups-agent/cgroups-agent.c
Imported Upstream version 218
[systemd.git] / src / cgroups-agent / cgroups-agent.c
CommitLineData
663996b3
MS
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
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
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
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
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
663996b3
MS
22#include <stdlib.h>
23
60f067b4 24#include "sd-bus.h"
663996b3 25#include "log.h"
60f067b4 26#include "bus-util.h"
663996b3
MS
27
28int main(int argc, char *argv[]) {
5eef597e 29 _cleanup_bus_close_unref_ sd_bus *bus = NULL;
60f067b4 30 int r;
663996b3
MS
31
32 if (argc != 2) {
33 log_error("Incorrect number of arguments.");
60f067b4 34 return EXIT_FAILURE;
663996b3
MS
35 }
36
37 log_set_target(LOG_TARGET_AUTO);
38 log_parse_environment();
39 log_open();
40
41 /* We send this event to the private D-Bus socket and then the
42 * system instance will forward this to the system bus. We do
43 * this to avoid an activation loop when we start dbus when we
44 * are called when the dbus service is shut down. */
45
60f067b4
JS
46 r = bus_open_system_systemd(&bus);
47 if (r < 0) {
48 /* If we couldn't connect we assume this was triggered
49 * while systemd got restarted/transitioned from
50 * initrd to the system, so let's ignore this */
f47781d8 51 log_debug_errno(r, "Failed to get D-Bus connection: %m");
60f067b4 52 return EXIT_FAILURE;
663996b3
MS
53 }
54
60f067b4
JS
55 r = sd_bus_emit_signal(bus,
56 "/org/freedesktop/systemd1/agent",
57 "org.freedesktop.systemd1.Agent",
58 "Released",
59 "s", argv[1]);
60 if (r < 0) {
f47781d8 61 log_debug_errno(r, "Failed to send signal message on private connection: %m");
60f067b4 62 return EXIT_FAILURE;
663996b3
MS
63 }
64
60f067b4 65 return EXIT_SUCCESS;
663996b3 66}