[PATCH 1/2] alfred: Use _exit() in the update command child process

Sven Eckelmann <[email protected]> Thu, 30 Jul 2026 21:18:55 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
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 <[email protected]>
---
 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