From 92b266d361dc3bad6be3d00eba21d40a53c325b0 Mon Sep 17 00:00:00 2001 From: "Michael P. Dubner" Date: Thu, 5 Apr 2018 17:12:34 +0300 Subject: [PATCH] rc: new call rc/pid - closes #2211 --- docs/content/rc.md | 5 +++++ fs/rc/internal.go | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/content/rc.md b/docs/content/rc.md index 709492efc..f85a73b2b 100644 --- a/docs/content/rc.md +++ b/docs/content/rc.md @@ -118,6 +118,11 @@ check that parameter passing is working properly. This returns an error with the input as part of its error string. Useful for testing error handling. +### rc/pid: Return PID of current process + +This returns PID of current process. +Useful for stopping rclone process. + ### rc/list: List all the registered remote control commands This lists all the registered remote control commands as a JSON map in diff --git a/fs/rc/internal.go b/fs/rc/internal.go index e462499a7..c3d36f816 100644 --- a/fs/rc/internal.go +++ b/fs/rc/internal.go @@ -2,7 +2,11 @@ package rc -import "github.com/pkg/errors" +import ( + "os" + + "github.com/pkg/errors" +) func init() { Add(Call{ @@ -30,6 +34,14 @@ Useful for testing error handling.`, This lists all the registered remote control commands as a JSON map in the commands response.`, }) + Add(Call{ + Path: "rc/pid", + Fn: rcPid, + Title: "Return PID of current process", + Help: ` +This returns PID of current process. +Useful for stopping rclone process.`, + }) } // Echo the input to the ouput parameters @@ -48,3 +60,10 @@ func rcList(in Params) (out Params, err error) { out["commands"] = registry.list() return out, nil } + +// Return PID of current process +func rcPid(in Params) (out Params, err error) { + out = make(Params) + out["pid"] = os.Getpid() + return out, nil +}