osext_plan9.go raw

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