From: Gilles Darold Date: Thu, 13 Jun 2019 07:38:45 +0000 (+0200) Subject: Fix use of progress bar on Windows operating system. Thanks to JMLessard for the... X-Git-Tag: v11.0~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6bd66394e986465b72be0ce3eb1b59efeb7f5c79;p=pgbadger Fix use of progress bar on Windows operating system. Thanks to JMLessard for the report. --- diff --git a/pgbadger b/pgbadger index 61f52fa..e8e358e 100755 --- a/pgbadger +++ b/pgbadger @@ -1427,12 +1427,11 @@ my $parallel_process = 0; # Open a pipe for interprocess communication my $reader = new IO::Handle; my $writer = new IO::Handle; -$pipe = IO::Pipe->new($reader, $writer); -$writer->autoflush(1); - # Fork the logger process -if ($progress) +if ($^O !~ /MSWin32|dos/i && $progress) { + $pipe = IO::Pipe->new($reader, $writer); + $writer->autoflush(1); spawn sub { &multiprocess_progressbar($global_totalsize); @@ -1548,7 +1547,10 @@ foreach my $logfile ( @given_log_files ) } my $minproc = 1; -$minproc = 0 if (!$progress); +if ($^O =~ /MSWin32|dos/i || !$progress) +{ + $minproc = 0; +} # Wait for all child processes to localdie except for the logger while (scalar keys %RUNNING_PIDS > $minproc) { @@ -2800,7 +2802,7 @@ sub update_progress_bar { my ($tmpoutfile, $nlines, $stop_offset, $totalsize, $cursize, $old_queries_count, $old_errors_count) = @_; - if (!$tmpoutfile) { + if (!$tmpoutfile || not defined $pipe) { if ($progress && (($nlines % $NUMPROGRESS) == 0)) { if ($totalsize) { print STDERR &progress_bar($$cursize, $stop_offset || $totalsize, 25, '='); @@ -2888,7 +2890,7 @@ sub process_file { if ($progress && ($getout != 1)) { - if (!$tmpoutfile) + if (!$tmpoutfile || not defined $pipe) { if ($totalsize) { @@ -3663,7 +3665,7 @@ sub process_file $cursize = $totalsize; } - if (!$tmpoutfile) + if (!$tmpoutfile|| not defined $pipe) { if ($totalsize) {