]>
Commit | Line | Data |
---|---|---|
8c47c732 LP |
1 | /*** |
2 | This file is part of systemd. | |
3 | ||
4 | Copyright 2010 Lennart Poettering | |
5 | ||
6 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
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 | |
8c47c732 LP |
9 | (at your option) any later version. |
10 | ||
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 | |
5430f7f2 | 14 | Lesser General Public License for more details. |
8c47c732 | 15 | |
5430f7f2 | 16 | You should have received a copy of the GNU Lesser General Public License |
8c47c732 LP |
17 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
18 | ***/ | |
19 | ||
20 | #include <unistd.h> | |
21 | ||
8dd4c05b LP |
22 | #include "sd-daemon.h" |
23 | ||
f06dcdca | 24 | #include "parse-util.h" |
8dd4c05b | 25 | #include "strv.h" |
8c47c732 LP |
26 | |
27 | int main(int argc, char*argv[]) { | |
8dd4c05b LP |
28 | _cleanup_strv_free_ char **l = NULL; |
29 | int n, i; | |
f06dcdca ZJS |
30 | usec_t duration = USEC_PER_SEC / 10; |
31 | ||
32 | if (argc >= 2) { | |
33 | unsigned x; | |
34 | ||
35 | assert_se(safe_atou(argv[1], &x) >= 0); | |
36 | duration = x * USEC_PER_SEC; | |
37 | } | |
8dd4c05b LP |
38 | |
39 | n = sd_listen_fds_with_names(false, &l); | |
40 | if (n < 0) { | |
41 | log_error_errno(n, "Failed to get listening fds: %m"); | |
42 | return EXIT_FAILURE; | |
43 | } | |
44 | ||
45 | for (i = 0; i < n; i++) | |
46 | log_info("fd=%i name=%s\n", SD_LISTEN_FDS_START + i, l[i]); | |
8c47c732 | 47 | |
308d72dc LP |
48 | sd_notify(0, |
49 | "STATUS=Starting up"); | |
f06dcdca | 50 | usleep(duration); |
308d72dc LP |
51 | |
52 | sd_notify(0, | |
53 | "STATUS=Running\n" | |
54 | "READY=1"); | |
f06dcdca | 55 | usleep(duration); |
308d72dc LP |
56 | |
57 | sd_notify(0, | |
58 | "STATUS=Reloading\n" | |
59 | "RELOADING=1"); | |
f06dcdca | 60 | usleep(duration); |
308d72dc | 61 | |
8c47c732 LP |
62 | sd_notify(0, |
63 | "STATUS=Running\n" | |
64 | "READY=1"); | |
f06dcdca | 65 | usleep(duration); |
308d72dc LP |
66 | |
67 | sd_notify(0, | |
68 | "STATUS=Quitting\n" | |
69 | "STOPPING=1"); | |
f06dcdca | 70 | usleep(duration); |
8c47c732 | 71 | |
8dd4c05b | 72 | return EXIT_SUCCESS; |
8c47c732 | 73 | } |