From 177108f7c6de8af36164ea247267e91851432222 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Wed, 6 Aug 2008 18:31:28 -0700 Subject: Use unbuffered writes in pipe mode. --- scripts/vyatta-nat-translations.pl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-nat-translations.pl b/scripts/vyatta-nat-translations.pl index 681845f..a272725 100755 --- a/scripts/vyatta-nat-translations.pl +++ b/scripts/vyatta-nat-translations.pl @@ -189,16 +189,15 @@ if (! -f $conntrack) { my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 0); my ($xml, $data); +# flush stdout after every write for pipe mode +$! = 1 if defined $pipe; + if (defined $verbose) { printf($verbose_format, 'Pre-NAT src', 'Pre-NAT dst', 'Post-NAT src', 'Post-NAT dst'); } else { printf($format, 'Pre-NAT', 'Post-NAT', 'Type', 'Prot', 'Timeout'); - if (defined $pipe) { - # flush stdout after every write - $| = 1; - print " Type"; - } + print " Type" if defined $pipe; print "\n"; } -- cgit v1.2.3