#!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; my $file_pipe = "$$".'_pipe'; system('mkfifo',$file_pipe)==0 or die $!; my $p_read; open $p_read,'+<',$file_pipe or die $!; # needs '+<' instead of '<' to be nonblocking $SIG{USR1} = \&on_usr1; my $loop = Glib::MainLoop->new( 'default', FALSE ); #test non-blocking is working my $count = 1; print "$count\n"; #my $timer = Glib::Timeout->add (1000, \&timer_callback, undef, 1 ); $loop->run; sub on_usr1 { my $sig = shift; print "somebody told me $sig\n"; } sub timer_callback{ $count++; print "$count\n"; return 1; }