Implement atexit.rmtree

This commit is contained in:
Kovid Goyal 2025-01-05 11:04:23 +05:30
parent 0d5bcff353
commit 25cb73511f
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 0 deletions

View file

@ -44,6 +44,14 @@ def read():
p.stdin.flush()
select.select(readers, [], [], 10)
self.ae(read(), str(i+1))
sdir = os.path.join(self.tdir, 'd')
os.mkdir(sdir)
p.stdin.write(f'rmtree {sdir}\n'.encode())
p.stdin.flush()
open(os.path.join(sdir, 'f'), 'w').close()
select.select(readers, [], [], 10)
self.ae(read(), str(i+2))
self.assertTrue(os.listdir(self.tdir))
# Ensure child is ignoring signals

View file

@ -44,6 +44,11 @@ func main() (rc int, err error) {
fmt.Fprintln(os.Stderr, "Failed to remove:", rest, "with error:", err)
rc = 1
}
case "rmtree":
if err := os.RemoveAll(rest); err != nil {
fmt.Fprintln(os.Stderr, "Failed to remove:", rest, "with error:", err)
rc = 1
}
}
}
}