process.go 347 B

1234567891011121314151617181920212223242526
  1. package proc
  2. import (
  3. "os"
  4. "path/filepath"
  5. )
  6. var (
  7. procName string
  8. pid int
  9. )
  10. func init() {
  11. procName = filepath.Base(os.Args[0])
  12. pid = os.Getpid()
  13. }
  14. // Pid returns pid of current process.
  15. func Pid() int {
  16. return pid
  17. }
  18. // ProcessName returns the processname, same as the command name.
  19. func ProcessName() string {
  20. return procName
  21. }