Commit Diff


commit - 89b827214e68c971373e4ceca0eeb36663ab6b02
commit + 3662c36f8b9e00bf7bc822238a379e542b15320e
blob - 8d11358f2c226c6c3c9d113a67c5801b779320fc
blob + 648500bf17d5e80bbfe5a0243fdf3522d167598c
--- deskd.c
+++ deskd.c
@@ -134,6 +134,16 @@ main(const int argc, char *argv[])
 		return 1;
 	}
 
+	/*
+	 * Switch stdout to fully buffered mode. CGI route handlers
+	 * make dozens of small printf/fputs calls; without this, each
+	 * newline triggers a write(2) syscall because stdout is
+	 * line-buffered when connected to a pipe. Full buffering
+	 * batches the entire response into one or two writes that
+	 * flush automatically when the process exits.
+	 */
+	setvbuf(stdout, NULL, _IOFBF, 0);
+
 	if (argc > 1 && strcmp(argv[1], "migrate") == 0) {
 		handle_migrate();
 		return 0;