This comes at the expense of having Try::Tiny as additional dependency,
but I think Try::Tiny is widely available.
use Getopt::Long;
use Pod::Usage;
use IPC::Run qw(start pump);
+use Try::Tiny;
use AnyEvent::I3;
use AnyEvent;
use v5.10;
$out .= "\n";
$outputs->{$name}->{cmd_input} = $out;
- pump $outputs->{$name}->{cmd} while length $outputs->{$name}->{cmd_input};
+ try {
+ pump $outputs->{$name}->{cmd} while length $outputs->{$name}->{cmd_input};
+ } catch {
+ warn "Could not write to dzen2";
+ exit 1;
+ }
}
}