diff options
Diffstat (limited to 'log.pl')
-rwxr-xr-x | log.pl | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#!/usr/bin/perl -w + +use strict; +use AnyEvent; +use AnyEvent::Socket; +use AnyEvent::Handle; + +my $log_socket = '/tmp/log.sock'; + +my $cv = AnyEvent->condvar; + +tcp_connect 'unix/', $log_socket, sub { + my ($fh) = @_ or die "Unable to connect: $!"; + + my $h; $h = new AnyEvent::Handle + fh => $fh, + on_eof => sub { $h->destroy; $cv->send; }, + on_error => sub { die("Connection closed."); }; + + while (<STDIN>) { + $h->push_write($_); + } + + $h->push_shutdown; + $h->destroy; + $cv->send; +}; + +$cv->recv; |