#!/usr/bin/perl # # fifo-safety # clears out $Conf::readfile (only if $Conf::readfile_isfifo is true) # when it has more than $max_size in it keeps syslogd from blocking # when readlog is not running # # smtp-poplock package by David Harris # use Fcntl; use strict; BEGIN: { require "/etc/smtp-poplock.conf" }; my $max_size = 1024; &main; sub main { exit 0 if ( not $Conf::readfile_isfifo ); my $fifo = $Conf::readfile; my $size = -s $fifo; exit 0 if ( $size < $max_size ); if ( lc shift @ARGV eq '-v' ) { print "Clearing out fifo $fifo\n"; print "size = $size\n"; } sysopen(FILE, $fifo, O_NONBLOCK | O_RDONLY) or die "error opening $fifo for noblocking, readonly io" ; my $buf; while ( 0 != sysread(FILE, $buf, 1024) ) { ; } close(FILE) or die "error closing $fifo"; exit 0; }