]> git.proxmox.com Git - systemd.git/blame - src/test/test-daemon.c
Imported Upstream version 227
[systemd.git] / src / test / test-daemon.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
22#include <unistd.h>
23
6300502b
MP
24#include "sd-daemon.h"
25
26#include "strv.h"
663996b3
MS
27
28int main(int argc, char*argv[]) {
6300502b
MP
29 _cleanup_strv_free_ char **l = NULL;
30 int n, i;
31
32 n = sd_listen_fds_with_names(false, &l);
33 if (n < 0) {
34 log_error_errno(n, "Failed to get listening fds: %m");
35 return EXIT_FAILURE;
36 }
37
38 for (i = 0; i < n; i++)
39 log_info("fd=%i name=%s\n", SD_LISTEN_FDS_START + i, l[i]);
663996b3 40
5eef597e
MP
41 sd_notify(0,
42 "STATUS=Starting up");
43 sleep(5);
44
45 sd_notify(0,
46 "STATUS=Running\n"
47 "READY=1");
48 sleep(5);
49
50 sd_notify(0,
51 "STATUS=Reloading\n"
52 "RELOADING=1");
663996b3 53 sleep(5);
5eef597e 54
663996b3
MS
55 sd_notify(0,
56 "STATUS=Running\n"
57 "READY=1");
5eef597e
MP
58 sleep(5);
59
60 sd_notify(0,
61 "STATUS=Quitting\n"
62 "STOPPING=1");
63 sleep(5);
663996b3 64
6300502b 65 return EXIT_SUCCESS;
663996b3 66}