Skip to content

Commit

Permalink
syscall: ignore getwd errors when fixing working directory on Plan 9
Browse files Browse the repository at this point in the history
In Plan 9, goroutines can run in different processes,
which don't share their working directory. However,
Go expects the working directory to be program-wide.

We use a Fixwd function to fix the working directory
before calling system calls which depend on the
working directory.

In fixwdLocked, the working directory is not fixed
when getwd returns an error. However, an error can
happen is some cases, notably when the directory
has been previously removed in another process.

Fixes #10422.

Change-Id: Ie0c36f97c4b5ebe27ff0ead360987c5b35f825e4
Reviewed-on: https://go-review.googlesource.com/8800
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
  • Loading branch information
0intro committed Apr 12, 2015
1 parent 63c16b1 commit 7d3f81a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/syscall/pwd_plan9.go
Expand Up @@ -29,10 +29,8 @@ func fixwdLocked() {
if !wdSet {
return
}
wd, err := getwd()
if err != nil {
return
}
// always call chdir when getwd returns an error
wd, _ := getwd()
if wd == wdStr {
return
}
Expand Down

0 comments on commit 7d3f81a

Please sign in to comment.