$SIG{'ALRM'} = sub { quit("ERROR => Timeout while opening FIFO [$ +conf{'fifo'}]. Possible solution: configure syslogd to log to this F +IFO and restart syslogd.", 1); }; #### ############################################################################################### ## FUNCTION: ## openFIFO ( $filename ) ## ## ## DESCRIPTION: ## Opens the fifo $filename for reading and attaches it to the filehandle "FIFO". Returns 0 on success ## and non-zero on failure. Error codes are listed below, and the error message gets set in ## global variable $!. ## ## ## Example: ## openFIFO ("/var/log/fifo.rdp_monitorLogwatch"); ## ############################################################################################### sub openFIFO { ## Get the incoming filename my $filename = $_[0]; ## Make sure our fifo exists, and if the fifo doesn't exist then create it if ( ! -p $filename ) { quit("ERROR => FIFO does not exist or is not a FIFO at [$conf{'fifo'}]\nDid you forget to create it and configure syslogd to log to it?\n", 1); } ## Open the FIFO socket we're supposed to listen to and attach it to a filehandle $SIG{'ALRM'} = sub { quit("ERROR => Timeout while opening FIFO [$conf{'fifo'}]. Possible solution: configure syslogd to log to this FIFO and restart syslogd.", 1); }; alarm(10); open (FIFO,"< $filename") or return(1); alarm(0); ## Return success return(0); }