aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat
diff options
context:
space:
mode:
Diffstat (limited to 'internal/syscallcompat')
-rw-r--r--internal/syscallcompat/sys_darwin.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go
index 5bc5fba..5504860 100644
--- a/internal/syscallcompat/sys_darwin.go
+++ b/internal/syscallcompat/sys_darwin.go
@@ -134,12 +134,13 @@ func Dup3(oldfd int, newfd int, flags int) (err error) {
// Poor man's Fchownat.
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
+ chdirMutex.Lock()
+ defer chdirMutex.Unlock()
cwd, err := syscall.Open(".", syscall.O_RDONLY, 0)
if err != nil {
return err
}
- chdirMutex.Lock()
- defer chdirMutex.Unlock()
+ defer syscall.Close(cwd)
err = syscall.Fchdir(dirfd)
if err != nil {
return err