Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] mpris-proxy: Line-buffer stdout
@ 2026-09-29  0:34 Seonggon Cho
  2026-09-29  2:12 ` [BlueZ] " bluez.test.bot
  2026-09-29  2:45 ` [PATCH BlueZ v2] " Seonggon Cho
  0 siblings, 2 replies; 5+ messages in thread
From: Seonggon Cho @ 2026-09-29  0:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Seonggon Cho

mpris-proxy reports adapter and player changes with printf() but never
flushes stdout. When it runs as a service (tools/mpris-proxy.service)
stdout is a pipe to the journal, so glibc fully buffers it and nothing
is written until 4 KiB have accumulated or the process exits.

On a system whose Bluetooth adapter went away and came back every two
minutes, the "Bluetooth Adapter /org/bluez/hci0 removed" and "... found"
messages reached the journal in bursts of exactly 100 lines (about
4096 bytes), all carrying the timestamp of the flush rather than of the
event, i.e. up to about 80 minutes late.

Set stdout to line buffered at startup, as bt_shell_init() already does,
so every message reaches the journal with an accurate timestamp.

Assisted-by: Claude:claude-fable-5-1
---
 tools/mpris-proxy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/mpris-proxy.c b/tools/mpris-proxy.c
index 1d7a421e9..4a8dd71e2 100644
--- a/tools/mpris-proxy.c
+++ b/tools/mpris-proxy.c
@@ -2954,6 +2954,10 @@ int main(int argc, char *argv[])
 	guint owner_watch, properties_watch, signal_watch;
 	struct sigaction sa;
 
+	/* stdout is a pipe to the journal when running as a service, so make
+	 * it line buffered to get the messages out as they happen. */
+	setlinebuf(stdout);
+
 	context = g_option_context_new(NULL);
 	g_option_context_add_main_entries(context, options, NULL);
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-30 15:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-29  0:34 [PATCH BlueZ] mpris-proxy: Line-buffer stdout Seonggon Cho
2026-09-29  2:12 ` [BlueZ] " bluez.test.bot
2026-09-29  2:45 ` [PATCH BlueZ v2] " Seonggon Cho
2026-09-29  7:56   ` [BlueZ,v2] " bluez.test.bot
2026-09-30 15:40   ` [PATCH BlueZ v2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox