]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: i3-wsbar: properly catch errors when writing to child process
authorMichael Stapelberg <michael@stapelberg.de>
Wed, 16 Jun 2010 17:26:55 +0000 (19:26 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 16 Jun 2010 17:27:56 +0000 (19:27 +0200)
This comes at the expense of having Try::Tiny as additional dependency,
but I think Try::Tiny is widely available.

i3-wsbar

index b1a50c40fd46a5131babf11d304dea06f7e463df..63583b081dc45e56c581f4d2690a8a843e86679d 100755 (executable)
--- a/i3-wsbar
+++ b/i3-wsbar
@@ -7,6 +7,7 @@ use warnings;
 use Getopt::Long;
 use Pod::Usage;
 use IPC::Run qw(start pump);
+use Try::Tiny;
 use AnyEvent::I3;
 use AnyEvent;
 use v5.10;
@@ -182,7 +183,12 @@ sub update_output {
         $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;
+        }
     }
 }