From c667c9b128af7a9d8344459c8c65ee9ee8703f02 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 17 Mar 2009 10:38:08 -0700 Subject: Use select to avoid passing output path around Easier to just use 'select' in perl to avoid passing file descriptor everywhere. --- scripts/vyatta-qos.pl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'scripts/vyatta-qos.pl') diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl index 8b8b978..328e8d7 100755 --- a/scripts/vyatta-qos.pl +++ b/scripts/vyatta-qos.pl @@ -157,26 +157,24 @@ sub update_interface { # When doing debugging just echo the commands my $out; - if ( defined $debug ) { - open $out, '>-' - or die "can't open stdout: $!"; - } - else { + unless ($debug) { open $out, "|-" or exec qw:sudo /sbin/tc -batch -: or die "Tc setup failed: $!\n"; + + select $out; } - $shaper->commands( $out, $device, $direction ); - if ( !close $out && !defined $debug ) { + $shaper->commands( $device, $direction ); + return if ($debug); + select STDOUT; + unless (close $out) { # cleanup any partial commands delete_interface( $device, $direction ); # replay commands to stdout - open $out, '>-'; - $shaper->commands( $out, $device, $direction ); - close $out; + $shaper->commands($device, $direction ); die "TC command failed."; } } -- cgit v1.2.3