summaryrefslogtreecommitdiffstats
path: root/pid.go
blob: 3bdb1f34fb8ad06b0db672187d20e629ea9fde85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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{})
}