1403 |
return ($NoHup,$NumberOfProcessors); |
return ($NoHup,$NumberOfProcessors); |
1404 |
} |
} |
1405 |
|
|
|
=head3 ManageFileLocking |
|
|
Definition: |
|
|
$model->ManageFileLocking($FileHandle,$Operation,$UseFcntl); |
|
|
Description: |
|
|
This function handles all file locking for the FIGMODEL package. Possible values for $Operation are: |
|
|
LOCK_EX: exclusive lock for writing |
|
|
LOCK_SH: shared lock for simultaneous reading |
|
|
LOCK_UN: removes the lock |
|
|
Example: |
|
|
=cut |
|
|
|
|
|
sub ManageFileLocking { |
|
|
my($FileHandle,$Operation,$UseFcntl) = @_; |
|
|
|
|
|
#Qualifying the filehandle |
|
|
$FileHandle = qualify_to_ref($FileHandle, caller()); |
|
|
|
|
|
#Implementing the lock using flock |
|
|
if (!defined($UseFcntl) || $UseFcntl == 0) { |
|
|
if ($Operation == LOCK_EX) { |
|
|
my $arg = pack("ssll", F_WRLCK, SEEK_SET, 0, 0); |
|
|
my $rc = fcntl($FileHandle, F_SETLKW, $arg); |
|
|
return $rc; |
|
|
} elsif ($Operation == LOCK_SH) { |
|
|
my $arg = pack("ssll", F_RDLCK, SEEK_SET, 0, 0); |
|
|
my $rc = fcntl($FileHandle, F_SETLKW, $arg); |
|
|
return $rc; |
|
|
} elsif ($Operation == LOCK_UN) { |
|
|
my $arg = pack("ssll", F_UNLCK, SEEK_SET, 0, 0); |
|
|
my $rc = fcntl($FileHandle, F_SETLKW, $arg); |
|
|
return $rc; |
|
|
} |
|
|
} else { |
|
|
return CORE::flock($FileHandle, $Operation); |
|
|
} |
|
|
} |
|
|
|
|
1406 |
=head3 runexecutable |
=head3 runexecutable |
1407 |
Definition: |
Definition: |
1408 |
my $OutputArray = runexecutable($Command); |
my $OutputArray = runexecutable($Command); |