From c581ed717ad2cc4be90c46253baa44a0d3ba5b80 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 6 Apr 2015 14:07:50 +0200 Subject: [PATCH] gpg: Add new option --debug-iolbf. * g10/gpg.c (oDebugIOLBF): new. (opts): Add --debug-iolbf. (main): Set option. -- This option is convenient for debugging to make sure that debug output to stderr is synced with output to stdout. Signed-off-by: Werner Koch --- doc/gpg.texi | 5 +++++ g10/gpg.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/gpg.texi b/doc/gpg.texi index 741271ec4..393cf2417 100644 --- a/doc/gpg.texi +++ b/doc/gpg.texi @@ -2451,6 +2451,11 @@ be given in C syntax (e.g. 0x0042). @opindex debug-all Set all useful debugging flags. +@item --debug-iolbf +@opindex debug-iolbf +Set stdout into line buffered mode. This option is only honored when +given on the command line. + @item --faked-system-time @var{epoch} @opindex faked-system-time This option is only useful for testing; it sets the system time back or diff --git a/g10/gpg.c b/g10/gpg.c index a52d1d90d..aec6e808e 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -196,7 +196,7 @@ enum cmd_and_opt_values oDebug, oDebugLevel, oDebugAll, - oDebugCCIDDriver, + oDebugIOLBF, oStatusFD, oStatusFile, oAttributeFD, @@ -557,6 +557,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_p_u (oDebug, "debug", "@"), ARGPARSE_s_s (oDebugLevel, "debug-level", "@"), ARGPARSE_s_n (oDebugAll, "debug-all", "@"), + ARGPARSE_s_n (oDebugIOLBF, "debug-iolbf", "@"), ARGPARSE_s_i (oStatusFD, "status-fd", "@"), ARGPARSE_s_s (oStatusFile, "status-file", "@"), ARGPARSE_s_i (oAttributeFD, "attribute-fd", "@"), @@ -2158,6 +2159,8 @@ main (int argc, char **argv) while( arg_parse( &pargs, opts) ) { if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll ) parse_debug++; + else if (pargs.r_opt == oDebugIOLBF) + es_setvbuf (es_stdout, NULL, _IOLBF, 0); else if( pargs.r_opt == oOptions ) { /* yes there is one, so we do not try the default one, but * read the option file when it is encountered at the commandline @@ -2419,6 +2422,8 @@ main (int argc, char **argv) case oDebugAll: opt.debug = ~0; break; case oDebugLevel: debug_level = pargs.r.ret_str; break; + case oDebugIOLBF: break; /* Already set in pre-parse step. */ + case oStatusFD: set_status_fd ( translate_sys2libc_fd_int (pargs.r.ret_int, 1) ); break;