Skip to content

Commit a11b8e3

Browse files
committed
os: have RemoveAll loop on EINTR
Fixes #57966 Change-Id: Ia732d499ff9bd6e70030daab8fac42d1e204be37 Reviewed-on: https://go-review.googlesource.com/c/go/+/463076 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Nigel Tao <[email protected]> Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <[email protected]>
1 parent e216ee7 commit a11b8e3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/os/removeall_at.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ func removeAll(path string) error {
5858
func removeAllFrom(parent *File, base string) error {
5959
parentFd := int(parent.Fd())
6060
// Simple case: if Unlink (aka remove) works, we're done.
61-
err := unix.Unlinkat(parentFd, base, 0)
61+
err := ignoringEINTR(func() error {
62+
return unix.Unlinkat(parentFd, base, 0)
63+
})
6264
if err == nil || IsNotExist(err) {
6365
return nil
6466
}
@@ -75,7 +77,9 @@ func removeAllFrom(parent *File, base string) error {
7577

7678
// Is this a directory we need to recurse into?
7779
var statInfo syscall.Stat_t
78-
statErr := unix.Fstatat(parentFd, base, &statInfo, unix.AT_SYMLINK_NOFOLLOW)
80+
statErr := ignoringEINTR(func() error {
81+
return unix.Fstatat(parentFd, base, &statInfo, unix.AT_SYMLINK_NOFOLLOW)
82+
})
7983
if statErr != nil {
8084
if IsNotExist(statErr) {
8185
return nil
@@ -151,7 +155,9 @@ func removeAllFrom(parent *File, base string) error {
151155
}
152156

153157
// Remove the directory itself.
154-
unlinkError := unix.Unlinkat(parentFd, base, unix.AT_REMOVEDIR)
158+
unlinkError := ignoringEINTR(func() error {
159+
return unix.Unlinkat(parentFd, base, unix.AT_REMOVEDIR)
160+
})
155161
if unlinkError == nil || IsNotExist(unlinkError) {
156162
return nil
157163
}

0 commit comments

Comments
 (0)