Hello there,
My distribution Siebel::Srvrmgr tests are always failing with Solaris OS
due error of "Bad file number" when trying to use flock() to get a lock
on a file under a temporary directory created with Test::TempDir::Tiny.
Here is an example:
http://www.cpantesters.org/cpan/report/b6494902-43a3-11e5-a85a-e28fcaadd3a7
Doing some research about the issue, I found this post on Perlmonks:
http://www.perlmonks.org/bare/?node_id=289198
It seems I need to open the file for writing (that I need just to read)
to be able to get a exclusive lock. That's the current piece of code
that should take care of it:
if ( -e $lock_file ) {
open( my $in, '<', $lock_file )
or $logger->logdie("Cannot read $lock_file: $!");
flock( $in, LOCK_EX | LOCK_NB )
or $logger->logdie("Could not get exclusive lock on
$lock_file: $!");
local $/ = undef;
my $pid = <$in>;
close($in);
$logger->logdie(
"Previous executing is still running (PID $pid), cannot
execute")
if ( $pid != $$ );
}
Can someone please confirm this behaviour? Unfortunately I don't have a
Solaris OS hanging around for me to test it. :-)
Thank you,
Alceu