aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Net/IMAP/InterIMAP.pm
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-09-09 01:18:14 +0200
committerGuilhem Moulin <guilhem@fripost.org>2015-09-09 22:05:41 +0200
commit9fb0576765624cc27a1c06aebc9f4ef5df31ba30 (patch)
tree936285c732befc2d07dac609a856e95784074b6d /lib/Net/IMAP/InterIMAP.pm
parent64dc8a1ed4e15ce456a699184a4fff263f2c902f (diff)
Add a configuration option 'null-stderr=YES'.
To send STDERR to /dev/null for type=tunnel.
Diffstat (limited to 'lib/Net/IMAP/InterIMAP.pm')
-rw-r--r--lib/Net/IMAP/InterIMAP.pm16
1 files changed, 15 insertions, 1 deletions
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