B.A.T.M.A.N Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 1/2] alfred: Use _exit() in the update command child process
Date: Thu, 30 Jul 2026 21:18:55 +0200	[thread overview]
Message-ID: <20260730-bugfixes-notification-v1-1-d7cf675220e2@narfation.org> (raw)
In-Reply-To: <20260730-bugfixes-notification-v1-0-d7cf675220e2@narfation.org>

execute_update_command() prints a line to stdout and then fork()s a child
which runs the update command via system() before terminating with exit(0).

When alfred's stdout is is buffered, at the time of the fork() the buffer
still holds the just-printed "executing: ..." line along with any other
pending output, and the child receives a copy of that buffer. Calling
exit(0) in the child flushes its copy, and the parent flushes the same
content later, so every log line still buffered at fork() time is written
out twice.

Terminate the child with _exit(0) instead, which does not flush the stdio
buffers inherited from the parent, leaving the buffered output to be
written exactly once by the parent.

Fixes: 4ae4c749c0a4 ("alfred: Add "--update-command" parameter")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server.c b/server.c
index cb3fcfe..47613fd 100644
--- a/server.c
+++ b/server.c
@@ -364,7 +364,7 @@ static void execute_update_command(struct globals *globals)
 	script_pid = fork();
 	if (script_pid == 0) {
 		system(command);
-		exit(0);
+		_exit(0);
 	}
 
 	free(command);

-- 
2.47.3


  reply	other threads:[~2026-07-30 19:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 19:18 [PATCH 0/2] alfred: notifications: random fixes Sven Eckelmann
2026-07-30 19:18 ` Sven Eckelmann [this message]
2026-07-30 19:18 ` [PATCH 2/2] alfred: Announce changed data only after it was stored Sven Eckelmann

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=20260730-bugfixes-notification-v1-1-d7cf675220e2@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.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