summaryrefslogtreecommitdiffstats
path: root/pid.go
diff options
context:
space:
mode:
Diffstat (limited to 'pid.go')
-rw-r--r--pid.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pid.go b/pid.go
new file mode 100644
index 0000000..3bdb1f3
--- /dev/null
+++ b/pid.go
@@ -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{})
+}