X Tutup
Skip to content

Commit c157884

Browse files
committed
sd-daemon: add notify_start() and notify_on_cleanup() helper function
1 parent 1437822 commit c157884

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/shared/daemon-util.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* SPDX-License-Identifier: LGPL-2.1+ */
2+
#pragma once
3+
4+
#include <stdbool.h>
5+
6+
#include "sd-daemon.h"
7+
8+
#define NOTIFY_READY "READY=1\n" "STATUS=Processing requests..."
9+
#define NOTIFY_STOPPING "STOPPING=1\n" "STATUS=Shutting down..."
10+
11+
static inline const char *notify_start(const char *start, const char *stop) {
12+
if (start)
13+
(void) sd_notify(false, start);
14+
15+
return stop;
16+
}
17+
18+
/* This is intended to be used with _cleanup_ attribute. */
19+
static inline void notify_on_cleanup(const char **p) {
20+
if (p)
21+
(void) sd_notify(false, *p);
22+
}

src/shared/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ shared_sources = files('''
4141
cpu-set-util.h
4242
crypt-util.c
4343
crypt-util.h
44+
daemon-util.h
4445
dev-setup.c
4546
dev-setup.h
4647
dissect-image.c

0 commit comments

Comments
 (0)
X Tutup