Adding fflush() to ssh-agent so its output can be redirected to a file

Mike Bell openssh at mikebell.org
Tue Aug 2 14:36:24 EST 2011


Without this patch "ssh-agent -d > ~/ssh-agent.sh" will produce a zero byte file. Obviously a corner case, but for what I'm doing it's a show-stopper, and it _seems_ like an obvious improvement to correctness, rather than relying on implicit newline flushing with TTYs and flush-on-exit with the forking mode.

Not subscribed, so please CC me on any replies.

--- ssh-agent.c.orig    2011-08-01 20:42:08.890134187 -0700
+++ ssh-agent.c 2011-08-01 21:13:08.995357974 -0700
@@ -1281,6 +1281,7 @@
                printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name,
                    SSH_AUTHSOCKET_ENV_NAME);
                printf("echo Agent pid %ld;\n", (long)parent_pid);
+               fflush(stdout);
                goto skip;
        }
        pid = fork();



More information about the openssh-unix-dev mailing list