diff options
Diffstat (limited to 'pid.go')
-rw-r--r-- | pid.go | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +package goctl + +import ( + "os" + "strconv" +) + +var pid string + +type cmdPID struct{} + +func (cmd cmdPID) Name() string { + return "pid" +} + +func (cmd cmdPID) Help() string { + return "return the Unix process ID of this program" +} + +func (cmd cmdPID) Run(_ *Goctl, _ []string) string { + return pid +} + +func init() { + pid = strconv.Itoa(os.Getpid()) + builtinHandlers = append(builtinHandlers, cmdPID{}) +} |