Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with remove lock file in windows #41

Open
allaVolkov opened this issue May 16, 2019 · 2 comments
Open

problem with remove lock file in windows #41

allaVolkov opened this issue May 16, 2019 · 2 comments

Comments

@allaVolkov
Copy link

The following code works without errors in Unix and ends with error "Remove of lock file failed with: remove C:\Users\i019379\go\src\testLocking\lock.lock: The process cannot access the file because it is being used by another process." in Windows.
Thus in Windows it's impossible to remove lock file if more then one process tried to make locking.

func main(){
wd, _ := os.Getwd()
lockfile := filepath.Join(wd, "lock.lock")
lock1 := flock.New(lockfile)
locked1, _ := lock1.TryLock()
if !locked1{
fmt.Println("Error - First tryLock failed")
return
}
lock2 := flock.New(lockfile)
locked2, _ := lock2.TryLock()
if locked2{
fmt.Println("Second tryLock succeeded")
return
}
err := lock2.Unlock()
if err!=nil {
fmt.Println("Unlock of second lock failed")
return
}
err = lock1.Unlock()
if err!=nil {
fmt.Println("Unlock of first lock failed")
return
}
err = os.Remove(lockfile)
if err!=nil {
fmt.Println("Remove of lock file failed with: "+err.Error())
return
}
}

@theckman
Copy link
Member

@allaVolkov is this still present on v0.7.3? I don't have a Windows system I can test on.

@Integralist
Copy link

I'm seeing this error using Windows via GitHub Actions:

profile_test.go:790: want no error, have error saving config file: error writing to config file: write C:\Users\RUNNER~1\AppData\Local\Temp\fastly-temp-2402719425\config.toml: The process cannot access the file because another process has locked a portion of the file.
[139](https://github.com/fastly/cli/runs/7153347993?check_suite_focus=true#step:11:140)

I'm using version 0.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants