mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-07-04 12:03:43 +02:00
Adding src/pid/pid.go
This commit is contained in:
parent
2b823c1dd3
commit
060535f595
1 changed files with 28 additions and 0 deletions
28
src/pid/pid.go
Normal file
28
src/pid/pid.go
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
package pid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Get() (int) {
|
||||||
|
return os.Getpid()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Save(path string) (int, error) {
|
||||||
|
|
||||||
|
pid := Get()
|
||||||
|
fd, err := os.Create(path)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = fd.WriteString(strconv.Itoa(pid))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pid, nil
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue