if(os_is_win()) {
$dir = sys_native_abs_path($dir);
- $dir =~ s/\//\\\\/g;
+ if ($^O eq 'MSWin32') {
+ $dir =~ s/\//\\/g;
+ }
+ else {
+ $dir =~ s/\//\\\\/g;
+ }
my $handle = "handle";
if($ENV{"PROCESSOR_ARCHITECTURE"} =~ /64$/) {
$handle = "handle64";
if(checkcmd($handle)) {
# https://learn.microsoft.com/sysinternals/downloads/handle#usage
my $cmd = "$handle $dir -accepteula -nobanner";
- logmsg "Executing: '$cmd'\n";
+ logmsg "clearlocks: Executing query: '$cmd'\n";
my @handles = `$cmd`;
for my $tryhandle (@handles) {
# Skip the "No matching handles found." warning when returned
if($tryhandle =~ /^(\S+)\s+pid:\s+(\d+)\s+type:\s+(\w+)\s+([0-9A-F]+):\s+(.+)\r\r/) {
- logmsg "Found $3 lock of '$5' ($4) by $1 ($2)\n";
+ logmsg "clearlocks: Found $3 lock of '$5' ($4) by $1 ($2)\n";
# Ignore stunnel since we cannot do anything about its locks
if("$3" eq "File" && "$1" ne "tstunnel.exe") {
- logmsg "Killing IMAGENAME eq $1 and PID eq $2\n";
+ logmsg "clearlocks: Killing IMAGENAME eq $1 and PID eq $2\n";
# https://ss64.com/nt/taskkill.html
my $cmd = "taskkill.exe -f -t -fi \"IMAGENAME eq $1\" -fi \"PID eq $2\" >nul 2>&1";
- logmsg "Executing: '$cmd'\n";
+ logmsg "clearlocks: Executing kill: '$cmd'\n";
system($cmd);
$done = 1;
}