From: Jana Babovakova Date: Thu, 3 Apr 2025 12:23:43 +0000 (+0200) Subject: New: send_systemd_ready(), first suggested copy. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57a6cfbaada2b8e0702a45a33305136492d42688;p=thirdparty%2Fbird.git New: send_systemd_ready(), first suggested copy. To be corrected to work as expected and compile. --- diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 85acc2186..211c6e127 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -1001,6 +1001,20 @@ parse_args(int argc, char **argv) } } +static void +send_systemd_ready() +{ + const char *addrstr = getenv("NOTIFY_SOCKET"); + if (addrstr) { + int fd = socket(AF_UNIX, SOCK_DGRAM, 0); + struct sockaddr_un addr = { .sun_family = AF_UNIX }; + strncpy(addr.sun_path, sizeof(addr.sun_path), addrstr); + connect(fd, (struct sockaddr*) &addr); + write(fd, "READY=1"); + close(fd); + } +} + /* * Hic Est main() */ @@ -1069,6 +1083,8 @@ main(int argc, char **argv) dup2(0, 2); } + send_systemd_ready(); + main_thread_init(); write_pid_file();