From 9fb0576765624cc27a1c06aebc9f4ef5df31ba30 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 9 Sep 2015 01:18:14 +0200 Subject: Add a configuration option 'null-stderr=YES'. To send STDERR to /dev/null for type=tunnel. --- lib/Net/IMAP/InterIMAP.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/Net') diff --git a/lib/Net/IMAP/InterIMAP.pm b/lib/Net/IMAP/InterIMAP.pm index 966b965..db6f484 100644 --- a/lib/Net/IMAP/InterIMAP.pm +++ b/lib/Net/IMAP/InterIMAP.pm @@ -49,6 +49,7 @@ my %OPTIONS = ( password => qr/\A([\x01-\x7F]+)\z/, auth => qr/\A($RE_ATOM_CHAR+(?: $RE_ATOM_CHAR+)*)\z/, command => qr/\A(\/\P{Control}+)\z/, + 'null-stderr' => qr/\A(YES|NO)\z/i, compress => qr/\A($RE_ATOM_CHAR+(?: $RE_ATOM_CHAR+)*)\z/, SSL_fingerprint => qr/\A([A-Za-z0-9]+\$\p{AHex}+)\z/, SSL_cipher_list => qr/\A(\P{Control}+)\z/, @@ -248,11 +249,24 @@ sub new($%) { open STDIN, '<&', $rd or $self->panic("Can't dup: $!"); open STDOUT, '>&', $wd or $self->panic("Can't dup: $!"); + my $stderr2; + if (uc ($self->{'null-stderr'} // 'NO') eq 'YES') { + open $stderr2, '>&', *STDERR; + open STDERR, '>', '/dev/null' or $self->panic("Can't open /dev/null: $!"); + } + my $sigset = POSIX::SigSet::->new(SIGINT); my $oldsigset = POSIX::SigSet::->new(); sigprocmask(SIG_BLOCK, $sigset, $oldsigset) // $self->panic("Can't block SIGINT: $!"); - exec $command or $self->panic("Can't exec: $!"); + unless (exec $command) { + my $err = $!; + if (defined $stderr2) { + close STDERR; + open STDERR, '>&', $stderr2; + } + $self->panic("Can't exec: $err"); + } } # parent -- cgit v1.2.3