From fa19423d92e66ed656bcd55355fe11c426620adc Mon Sep 17 00:00:00 2001
From: Dan Sheppard <ds23@sanger.ac.uk>
Date: Fri, 10 Aug 2012 09:37:45 +0000
Subject: [PATCH] Don't try to lock or seek on logs to teletypes or pipes.
 Because you can't and you don't want to die.

---
 modules/Bio/EnsEMBL/Utils/ConversionSupport.pm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Utils/ConversionSupport.pm b/modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
index bb62eea4eb..23a03bc190 100644
--- a/modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+++ b/modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
@@ -1200,8 +1200,11 @@ sub log {
 
 sub lock_log {
   my ($self) = @_;
-  flock($self->{'_log_filehandle'},LOCK_EX) || die "Cannot lock log";
-  seek($self->{'_log_filehandle'},0,SEEK_END) || die "Cannot seek log";
+  
+  my $fh = $self->{'_log_filehandle'};
+  return if -t $fh or -p $fh; # Shouldn't lock such things   
+  flock($self->{'_log_filehandle'},LOCK_EX) || die "Cannot lock log: $!";
+  seek($self->{'_log_filehandle'},0,SEEK_END); # fail ok, prob not reg file
 }
 
 =head2 unlock_log
@@ -1212,6 +1215,9 @@ sub lock_log {
 
 sub unlock_log {
   my ($self) = @_;
+
+  my $fh = $self->{'_log_filehandle'};
+  return if -t $fh or -p $fh; # We don't lock such things
   # flush is implicit in flock
   flock($self->{'_log_filehandle'},LOCK_UN) || die "Cannot unlock log";
 }
-- 
GitLab