mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
pageant --foreground: close stdout after printing env setup.
This is a small refinement of my own to Marco Ricci's new mode introduced by the previous commit. If Pageant is being run by a parent process intending to make requests to it, then it's probably put a pipe on Pageant's stdout, and will be reading from that pipe to retrieve the environment setup commands. So it needs to know when it's read enough. Closing stdout immediately makes this as easy as possible, freeing the parent process of the need to count lines of output (and also know how many lines to expect): it can simply read until there's no more data. This also means there's no need to make stdout line-buffered, of course – the fclose will flush it anyway.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user