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 {
|
||||
return err
|
||||
} else {
|
||||
defer tmplock.Close()
|
||||
defer os.Remove(tmplock.Name())
|
||||
defer func(){
|
||||
tmplock.Close()
|
||||
os.Remove(tmplock.Name())
|
||||
}()
|
||||
}
|
||||
|
||||
_, err = tmplock.WriteString(fmt.Sprintf("%d\n", os.Getpid()))
|
||||
|
|
Loading…
Reference in New Issue