github.com/dara-project/godist@v0.0.0-20200823115410-e0c80c8f0c78/src/os/executable.go (about) 1 // Copyright 2016 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 package os 6 7 import ( 8 "dara" 9 "runtime" 10 ) 11 12 // Executable returns the path name for the executable that started 13 // the current process. There is no guarantee that the path is still 14 // pointing to the correct executable. If a symlink was used to start 15 // the process, depending on the operating system, the result might 16 // be the symlink or the path it pointed to. If a stable result is 17 // needed, path/filepath.EvalSymlinks might help. 18 // 19 // Executable returns an absolute path unless an error occurred. 20 // 21 // The main use case is finding resources located relative to an 22 // executable. 23 // 24 // Executable is not supported on nacl. 25 func Executable() (string, error) { 26 str, err := executable() 27 // DARA Instrumentation 28 if runtime.Is_dara_profiling_on() { 29 runtime.Dara_Debug_Print(func() { println("[EXECUTABLE]") }) 30 retInfo1 := dara.GeneralType{Type: dara.STRING} 31 copy(retInfo1.String[:], str) 32 retInfo2 := dara.GeneralType{Type: dara.ERROR, Unsupported: dara.UNSUPPORTEDVAL} 33 syscallInfo := dara.GeneralSyscall{dara.DSYS_EXECUTABLE, 0, 2, [10]dara.GeneralType{}, [10]dara.GeneralType{retInfo1, retInfo2}} 34 runtime.Report_Syscall_To_Scheduler(dara.DSYS_EXECUTABLE, syscallInfo) 35 } 36 return str, err 37 }