package Errors;

use strict;

use Conf;

BEGIN {
    @Conf::Ids = (@Conf::Ids, '$Header: /afs/sipb.mit.edu/project/zoned/src/RCS/Errors.pm,v 1.10 2018/10/10 23:57:20 jweiss Exp $ ');
};

sub notify {
    my $message = shift;
    my $mailto = shift;
    my $zephyrto = shift;
    my $mailsubj = shift;

    if (!$mailsubj) {
	$mailsubj = 'zoned';
    }

    if ($message and $mailto) {
	local $SIG{'PIPE'} = 'IGNORE';
	open(MAILTO, "|$Conf::mail -subject \'$mailsubj\' $mailto")
	    or die("Cannot open mail pipe: $!\n");

	print MAILTO $message
	    or die("Cannot write notification to mail pipe: $!\n");

	close(MAILTO)
	    or die("Cannot finish writing notification to mail pipe: $!\n");
    }

# Worried that zephyring was causing problems / hangs

#    if ($message and $zephyrto) {
#	local $SIG{'PIPE'} = 'IGNORE';
#	open(ZWR, "|$Conf::zwrite -q -d -n -s \'$mailsubj\' $zephyrto")
#	    or die("Cannot open zwrite pipe: $!\n");
#
#	print ZWR $message
#	    or die("Cannot write notification to zwrite pipe: $!\n");
#
#	close(ZWR);
#	    or die("Cannot finish writing notification to zwrite pipe: $!\n");
#    }
}

return 1;




