In my ruby script I have put below code to make sure the same script should not be executed again parallel when another process is already running.
if $0 == __FILE__
if File.new(__FILE__).flock(File::LOCK_EX | File::LOCK_NB)
if RbConfig::CONFIG['host_os'].include? 'linux'
linux_main
elsif RbConfig::CONFIG['host_os'].include? 'mingw'
windows_main
elsif RbConfig::CONFIG['host_os'].include? 'solaris'
solaris_main
end
end
end
__END__
But its not working as expected on Windows. I have initiated one process and when I run initiate another process on another powershell session its still running instead of coming out.
Any suggestion pls.