tmplock must be closed before removal
defer are called in LIFO style, so os.Remove was called before tmplock.Close
This commit is contained in:
parent
8a00983980
commit
5f902b89e3
|
@ -82,8 +82,10 @@ func (l Lockfile) TryLock() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer tmplock.Close()
|
defer func(){
|
||||||
defer os.Remove(tmplock.Name())
|
tmplock.Close()
|
||||||
|
os.Remove(tmplock.Name())
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = tmplock.WriteString(fmt.Sprintf("%d\n", os.Getpid()))
|
_, err = tmplock.WriteString(fmt.Sprintf("%d\n", os.Getpid()))
|
||||||
|
|
Loading…
Reference in New Issue