|
@@ -3,6 +3,8 @@ package reexec
|
|
|
import (
|
|
|
"fmt"
|
|
|
"os"
|
|
|
+ "os/exec"
|
|
|
+ "path/filepath"
|
|
|
)
|
|
|
|
|
|
var registeredInitializers = make(map[string]func())
|
|
@@ -28,3 +30,16 @@ func Init() bool {
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+// Self returns the path to the current processes binary
|
|
|
+func Self() string {
|
|
|
+ name := os.Args[0]
|
|
|
+
|
|
|
+ if filepath.Base(name) == name {
|
|
|
+ if lp, err := exec.LookPath(name); err == nil {
|
|
|
+ name = lp
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return name
|
|
|
+}
|