I have used below code to check single instance of replace.exe is running. When i create replace.exe and run on windows, one more file with name replace(without any extension) of 0 kb size is getting created.
I don't want that file to be created else i want to delete the file automatically after execution of replace.exe is over.
Please help me.thanks
use Fcntl qw(:flock);
# Check if any instance of this script is already running
my $lock = "replace";
sub LockOut ( ) {
&print_log ("A instance of this script is running. Therefore exiting. Please try after some time.");
print "A instance of this script is running. Therefore exiting. Please try after some time.";
exit 1;
}
open ( my $pid, '>', $lock );
flock ( $pid, LOCK_EX | LOCK_NB ) or LockOut( );