diff --git a/man/notify-selfcontained-example.c b/man/notify-selfcontained-example.c index 9a7553e3013..39f0dbe3fda 100644 --- a/man/notify-selfcontained-example.c +++ b/man/notify-selfcontained-example.c @@ -108,6 +108,10 @@ static int notify_reloading(void) { return notify(reload_message); } +static int notify_stopping(void) { + return notify("STOPPING=1"); +} + static volatile sig_atomic_t reloading = 0; static volatile sig_atomic_t terminating = 0; @@ -169,5 +173,13 @@ int main(int argc, char **argv) { sleep(5); } + r = notify_stopping(); + if (r < 0) { + fprintf(stderr, "Failed to report termination to $NOTIFY_SOCKET: %s\n", strerror(-r)); + return EXIT_FAILURE; + } + + /* Do some shutdown work here … */ + return EXIT_SUCCESS; }