# untested: my $stop = 0; $SIG{INT} = sub { $stop = 1 }; while (1) { my $fileno = fileno($linux_notify2->socket); my $v = ''; vec ($v, $fileno, 1) = 1; select($v, undef, undef, 0.1); last if $stop; if (vec($v, $fileno, 1)) { $linux_notify2->poll; ... } }