Commit fa19423d authored by Dan Sheppard's avatar Dan Sheppard
Browse files

Don't try to lock or seek on logs to teletypes or pipes. Because you can't

and you don't want to die.
parent 0af8360e
......@@ -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";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment