| 1 | This patch adds a --stdout=line|unbuf option that lets the |
| 2 | user change the buffering of stdout. |
| 3 | |
| 4 | To use this patch, run these commands for a successful build: |
| 5 | |
| 6 | patch -p1 <patches/stdout.diff |
| 7 | ./configure (optional if already run) |
| 8 | make |
| 9 | |
| 10 | based-on: a01e3b490eb36ccf9e704840e1b6683dab867550 |
| 11 | diff --git a/options.c b/options.c |
| 12 | --- a/options.c |
| 13 | +++ b/options.c |
| 14 | @@ -301,6 +301,7 @@ static int refused_partial, refused_progress, refused_delete_before; |
| 15 | static int refused_delete_during; |
| 16 | static int refused_inplace, refused_no_iconv; |
| 17 | static BOOL usermap_via_chown, groupmap_via_chown; |
| 18 | +static char *stdout_buffering; |
| 19 | static char *bwlimit_arg, *max_size_arg, *min_size_arg; |
| 20 | static char tmp_partialdir[] = ".~tmp~"; |
| 21 | |
| 22 | @@ -776,6 +777,7 @@ void usage(enum logcode F) |
| 23 | rprintf(F," --password-file=FILE read daemon-access password from FILE\n"); |
| 24 | rprintf(F," --list-only list the files instead of copying them\n"); |
| 25 | rprintf(F," --bwlimit=RATE limit socket I/O bandwidth\n"); |
| 26 | + rprintf(F," --stdout=line|unbuf change buffering of stdout\n"); |
| 27 | rprintf(F," --write-batch=FILE write a batched update to FILE\n"); |
| 28 | rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); |
| 29 | rprintf(F," --read-batch=FILE read a batched update from FILE\n"); |
| 30 | @@ -1008,6 +1010,7 @@ static struct poptOption long_options[] = { |
| 31 | {"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 }, |
| 32 | {"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 }, |
| 33 | {"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 }, |
| 34 | + {"stdout", 0, POPT_ARG_STRING, &stdout_buffering, 0, 0, 0 }, |
| 35 | {"remote-option", 'M', POPT_ARG_STRING, 0, 'M', 0, 0 }, |
| 36 | {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, |
| 37 | {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 }, |
| 38 | @@ -1793,6 +1796,13 @@ int parse_arguments(int *argc_p, const char ***argv_p) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | + if (stdout_buffering && !am_server) { |
| 43 | + if (*stdout_buffering == 'u') |
| 44 | + setvbuf(stdout, NULL, _IONBF, 0); |
| 45 | + else |
| 46 | + setvbuf(stdout, NULL, _IOLBF, 0); |
| 47 | + } |
| 48 | + |
| 49 | if (human_readable > 1 && argc == 2 && !am_server) { |
| 50 | /* Allow the old meaning of 'h' (--help) on its own. */ |
| 51 | usage(FINFO); |