aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_plan9.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2015-02-27 19:34:56 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2015-02-28 18:17:35 +0000
commitbc9748ee6bfba3632ab9c98c8dd475d8eacf41b3 (patch)
treeb4d2ac0050e33e862b24a0bb5dac35ebc33df480 /src/syscall/exec_plan9.go
parent2adc3bd6ef84aa8b3d730f5d0d96a30427f2ecc2 (diff)
downloadgo-bc9748ee6bfba3632ab9c98c8dd475d8eacf41b3.tar.xz
syscall: make pwd process-wide on Plan 9
On Plan 9, the pwd is apparently per-thread not per process. That means different goroutines saw different current directories, even changing within a goroutine as they were scheduled. Instead, track the the process-wide pwd protected by a mutex in the syscall package and set the current goroutine thread's pwd to the correct once at critical points. Fixes #9428 Change-Id: I928e90886355be4a95c2be834f5883e2b50fc0cf Reviewed-on: https://go-review.googlesource.com/6350 Reviewed-by: David du Colombier <0intro@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/syscall/exec_plan9.go')
-rw-r--r--src/syscall/exec_plan9.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/syscall/exec_plan9.go b/src/syscall/exec_plan9.go
index 45ee542bb0..ed358385b9 100644
--- a/src/syscall/exec_plan9.go
+++ b/src/syscall/exec_plan9.go
@@ -396,9 +396,15 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
return 0, err
}
+ destDir := attr.Dir
+ if destDir == "" {
+ wdmu.Lock()
+ destDir = wdStr
+ wdmu.Unlock()
+ }
var dir *byte
- if attr.Dir != "" {
- dir, err = BytePtrFromString(attr.Dir)
+ if destDir != "" {
+ dir, err = BytePtrFromString(destDir)
if err != nil {
return 0, err
}