Bugfix: i3-wsbar: properly catch errors when writing to child process

This comes at the expense of having Try::Tiny as additional dependency,
but I think Try::Tiny is widely available.
This commit is contained in:
Michael Stapelberg 2010-06-16 19:26:55 +02:00
parent 2c305b5429
commit 2fd8774249
1 changed files with 7 additions and 1 deletions

View File

@ -7,6 +7,7 @@ use warnings;
use Getopt::Long; use Getopt::Long;
use Pod::Usage; use Pod::Usage;
use IPC::Run qw(start pump); use IPC::Run qw(start pump);
use Try::Tiny;
use AnyEvent::I3; use AnyEvent::I3;
use AnyEvent; use AnyEvent;
use v5.10; use v5.10;
@ -182,7 +183,12 @@ sub update_output {
$out .= "\n"; $out .= "\n";
$outputs->{$name}->{cmd_input} = $out; $outputs->{$name}->{cmd_input} = $out;
try {
pump $outputs->{$name}->{cmd} while length $outputs->{$name}->{cmd_input}; pump $outputs->{$name}->{cmd} while length $outputs->{$name}->{cmd_input};
} catch {
warn "Could not write to dzen2";
exit 1;
}
} }
} }