Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rc: new call rc/pid - closes #2211

Michael P. Dubner92b266d361dc
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
+}