File: lock.go

package info (click to toggle)
golang-github-allan-simon-go-singleinstance 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 92 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package singleinstance

import (
	"io/ioutil"
	"strconv"
)

// If filename is a lock file, returns the PID of the process locking it
func GetLockFilePid(filename string) (pid int, err error) {
	contents, err := ioutil.ReadFile(filename)
	if err != nil {
		return
	}

	pid, err = strconv.Atoi(string(contents))
	return
}