osext_plan9.go 428 B

12345678910111213141516171819202122
  1. // Copyright 2012 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //+build !go1.8
  5. package osext
  6. import (
  7. "os"
  8. "strconv"
  9. "syscall"
  10. )
  11. func executable() (string, error) {
  12. f, err := os.Open("/proc/" + strconv.Itoa(os.Getpid()) + "/text")
  13. if err != nil {
  14. return "", err
  15. }
  16. defer f.Close()
  17. return syscall.Fd2path(int(f.Fd()))
  18. }