Linux bluetooth development
 help / color / mirror / Atom feed
From: Seonggon Cho <jmsmg1@me.com>
To: linux-bluetooth@vger.kernel.org
Cc: Seonggon Cho <jmsmg1@me.com>
Subject: [PATCH BlueZ] mpris-proxy: Line-buffer stdout
Date: Tue, 29 Sep 2026 00:34:32 +0000	[thread overview]
Message-ID: <20260929003432.3937487-1-jmsmg1@me.com> (raw)

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


             reply	other threads:[~2026-09-29  0:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29  0:34 Seonggon Cho [this message]
2026-09-29  2:12 ` [BlueZ] mpris-proxy: Line-buffer stdout 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
  -- strict thread matches above, loose matches on Subject: below --
2026-09-29  2:43 [PATCH BlueZ] " Seonggon Cho
2026-09-29  2:46 ` Seonggon Cho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929003432.3937487-1-jmsmg1@me.com \
    --to=jmsmg1@me.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox