Skip to content

Commit

Permalink
Implement atexit.rmtree
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jan 5, 2025
1 parent 0d5bcff commit 25cb735
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kitty_tests/atexit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tools/cmd/atexit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down

0 comments on commit 25cb735

Please sign in to comment.