[PATCH] Feature: s6-style readiness notification with flag
Emery Hemingway via Icecast-dev <[email protected]> Thu, 21 May 2026 11:12:43 +0000
| Newsgroups | gmane.comp.audio.icecast.devel |
|---|---|
| Message-ID | <[email protected]> |
If a file descriptor is specified by the -n flag then write a
newline to it when initialisation is complete.
https://skarnet.org/software/s6/notifywhenup.html
---
src/main.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/main.c b/src/main.c
index dd7eb7c..4b5db01 100644
--- a/src/main.c
+++ b/src/main.c
@@ -106,6 +106,7 @@
static bool background;
static char *pidfile = NULL;
+static int notify_fd = 0;
static void pidfile_update(ice_config_t *config, int always_try);
@@ -129,6 +130,7 @@ static void _print_usage(void)
printf("\t-c <file> Specify configuration file\n");
printf("\t-v or --version Display version info\n");
printf("\t-b Run icecast in the background\n");
+ printf("\t-n FD Write a newline to a file description when ready\n");
printf("\n");
}
@@ -329,6 +331,15 @@ static bool _parse_config_opts(int argc, char **argv, char *filename, size_t siz
} else {
return false;
}
+ } else if (strcmp(opt, "-n") == 0) {
+ if ((i + 1) < argc) {
+ if (sscanf(argv[++i], "%d", ¬ify_fd) != 1) {
+ fprintf(stderr, "FATAL: Invalid notify descriptor: %s\n", opt);
+ return false;
+ }
+ } else {
+ return false;
+ }
} else {
fprintf(stderr, "FATAL: Invalid option: %s\n", opt);
return false;
@@ -794,6 +805,14 @@ int main(int argc, char **argv)
event_stream_initialise();
event_emit_global("icecast-start");
+ if (notify_fd) {
+ /* Notify a service supervisor that we are ready */
+ if (write(notify_fd, "\n", 1) != 1) {
+ ICECAST_LOG_WARN("Failed to write ready notification to file descriptor %d.", notify_fd);
+ } else {
+ close(notify_fd);
+ };
+ }
_server_proc();
event_emit_global("icecast-stop");
--
2.52.0
_______________________________________________
Icecast-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]