2014-05-02 08:05:48 +00: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.
|
|
|
|
|
|
|
|
package osext
|
|
|
|
|
2014-07-06 21:13:10 +00:00
|
|
|
import (
|
2015-02-23 08:46:38 +00:00
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"syscall"
|
2014-07-06 21:13:10 +00:00
|
|
|
)
|
2014-05-02 08:05:48 +00:00
|
|
|
|
|
|
|
func executable() (string, error) {
|
2015-02-23 08:46:38 +00:00
|
|
|
f, err := os.Open("/proc/" + strconv.Itoa(os.Getpid()) + "/text")
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
return syscall.Fd2path(int(f.Fd()))
|
2014-05-02 08:05:48 +00:00
|
|
|
}
|