forked from External/grumble
Update for Go 1.
This commit is contained in:
parent
4114a83d64
commit
e46a65109f
31 changed files with 901 additions and 202 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) 2011 The Grumble Authors
|
||||
// The use of this source code is goverened by a BSD-style
|
||||
// license that can be found in the LICENSE-file.
|
||||
// Copyright (c) 2011 The Grumble Authors
|
||||
// The use of this source code is goverened by a BSD-style
|
||||
// license that can be found in the LICENSE-file.
|
||||
|
||||
package blobstore
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"syscall"
|
||||
)
|
||||
|
||||
// Acquire lockfile at path.
|
||||
// Acquire lockfile at path.
|
||||
func AcquireLockFile(path string) error {
|
||||
dir, fn := filepath.Split(path)
|
||||
lockfn := filepath.Join(dir, fn)
|
||||
|
|
@ -26,7 +26,8 @@ func AcquireLockFile(path string) error {
|
|||
|
||||
pid, err := strconv.Atoi(string(content))
|
||||
if err == nil {
|
||||
if syscall.Kill(pid, 0) == 0 {
|
||||
err = syscall.Kill(pid, 0)
|
||||
if err != nil {
|
||||
return ErrLocked
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +68,7 @@ func AcquireLockFile(path string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Release lockfile at path.
|
||||
// Release lockfile at path.
|
||||
func ReleaseLockFile(path string) error {
|
||||
return os.Remove(path)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue