github.com/lingyao2333/mo-zero@v1.4.1/core/proc/process.go (about)

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