From bc9748ee6bfba3632ab9c98c8dd475d8eacf41b3 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 27 Feb 2015 19:34:56 -0800 Subject: 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 TryBot-Result: Gobot Gobot --- src/syscall/exec_plan9.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/syscall/exec_plan9.go') 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 } -- cgit v1.3