runtime: abort stack scan in cases that we cannot unwind the stack
[gcc.git] / libgo / go / os / executable_solaris.go
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 "syscall"
9 _ "unsafe" // for go:linkname
10 )
11
12 // solarisExecutablePath is defined in the runtime package.
13 func solarisExecutablePath() string
14
15 var initCwd, initCwdErr = Getwd()
16
17 func executable() (string, error) {
18 path := solarisExecutablePath()
19 if len(path) == 0 {
20 path, err := syscall.Getexecname()
21 if err != nil {
22 return path, err
23 }
24 }
25 if len(path) > 0 && path[0] != '/' {
26 if initCwdErr != nil {
27 return path, initCwdErr
28 }
29 if len(path) > 2 && path[0:2] == "./" {
30 // skip "./"
31 path = path[2:]
32 }
33 return initCwd + "/" + path, nil
34 }
35 return path, nil
36 }