osext_plan9.go 411 B

123456789101112131415161718192021
  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. package osext
  5. import (
  6. "os"
  7. "strconv"
  8. "syscall"
  9. )
  10. func executable() (string, error) {
  11. f, err := os.Open("/proc/" + strconv.Itoa(os.Getpid()) + "/text")
  12. if err != nil {
  13. return "", err
  14. }
  15. defer f.Close()
  16. return syscall.Fd2path(int(f.Fd()))
  17. }