syncthing/Godeps/_workspace/src/github.com/kardianos/osext/osext_procfs.go

29 lines
678 B
Go
Raw Normal View History

2014-05-02 10:05:48 +02:00
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build linux netbsd openbsd solaris dragonfly
2014-05-02 10:05:48 +02:00
package osext
import (
"errors"
2014-09-28 23:10:43 +02:00
"fmt"
2014-05-02 10:05:48 +02:00
"os"
"runtime"
)
func executable() (string, error) {
switch runtime.GOOS {
case "linux":
return os.Readlink("/proc/self/exe")
case "netbsd":
return os.Readlink("/proc/curproc/exe")
case "openbsd", "dragonfly":
2014-05-02 10:05:48 +02:00
return os.Readlink("/proc/curproc/file")
2014-09-28 23:10:43 +02:00
case "solaris":
return os.Readlink(fmt.Sprintf("/proc/%d/path/a.out", os.Getpid()))
2014-05-02 10:05:48 +02:00
}
return "", errors.New("ExecPath not implemented for " + runtime.GOOS)
}