| // Copyright 2015 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // The working directory in Plan 9 is effectively per P, so different |
| // goroutines and even the same goroutine as it's rescheduled on |
| // different Ps can see different working directories. |
| // Instead, track a Go process-wide intent of the current working directory, |
| // and switch to it at important points. |
| wdmu sync.Mutex // guards following |
| if err := chdir(wdStr); err != nil { |
| // goroutine-specific getwd |
| func getwd() (wd string, err error) { |
| fd, err := open(".", O_RDONLY) |
| func Getwd() (wd string, err error) { |
| func Chdir(path string) error { |
| if err := chdir(path); err != nil { |