diff --git a/doc/man-pageant.but b/doc/man-pageant.but index 1ece3aec..55c15612 100644 --- a/doc/man-pageant.but +++ b/doc/man-pageant.but @@ -193,6 +193,15 @@ to standard input. This is useful if Pageant is spawned by a parent process that controls or otherwise programmatically interfaces with Pageant. +\lcont{ + +After Pageant prints its environment setup commands, it closes its +standard output, so that the parent process can simply read until it +receives EOF, instead of having to know how many lines of output to +expect. + +} + \S{pageant-manpage-client} CLIENT OPTIONS The following options tell Pageant to operate in client mode, diff --git a/unix/pageant.c b/unix/pageant.c index 43eb1e88..4d7a4fa5 100644 --- a/unix/pageant.c +++ b/unix/pageant.c @@ -1224,8 +1224,10 @@ void run_agent(FILE *logfp, const char *symlink_path) } else if (life == LIFE_PERM) { pageant_fork_and_print_env(false); } else if (life == LIFE_FOREGROUND) { - setvbuf(stdout, NULL, _IOLBF, 0); pageant_print_env(getpid()); + /* Close stdout, so that a parent process at the other end of a pipe + * can do the simple thing of reading up to EOF */ + fclose(stdout); } else if (life == LIFE_DEBUG) { /* Force stdout to be line-buffered in preference to unbuffered, so * that if diagnostic output is being piped somewhere, it will arrive