diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2015-07-24 16:55:21 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-07-24 17:35:16 +0200 |
commit | b2beb8ab9149ea4a4977209160ab8a9f15f05ab7 (patch) | |
tree | 8ff94d71902b137e8b461477212d9c45deddc49e /lib/Net/IMAP | |
parent | a8445f6da256a09bac321a0bd2c23e3b8424caf4 (diff) |
Exit gracefully when catching a SIGHUP.
Diffstat (limited to 'lib/Net/IMAP')
-rw-r--r-- | lib/Net/IMAP/Sync.pm | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Net/IMAP/Sync.pm b/lib/Net/IMAP/Sync.pm index bb99dcb..b864db8 100644 --- a/lib/Net/IMAP/Sync.pm +++ b/lib/Net/IMAP/Sync.pm @@ -387,8 +387,9 @@ sub new($%) { # Close handles when the Net::IMAP::Sync object is destroyed. sub DESTROY($) { my $self = shift; - foreach (qw/STDIN STDOUT/) { - $self->{$_}->close() if defined $self->{$_} and $self->{$_}->opened(); + if (defined $self->{STDIN} and $self->{STDIN}->opened() and + defined $self->{STDOUT} and $self->{STDOUT}->opened()) { + $self->logout(); } $self->{STDERR}->close() if defined $self->{STDERR} and $self->{STDERR}->opened() and $self->{STDERR} ne \*STDERR; @@ -1394,6 +1395,9 @@ sub _resp($$;$$$) { if (s/\A\* //) { if (s/\ABYE //) { + foreach (qw/STDIN STDOUT/) { + $self->{$_}->close() if defined $self->{$_} and $self->{$_}->opened(); + } exit 0; } elsif (s/\A(?:OK|NO|BAD) //) { |