Prevent exit callback instance leaks

De-references pty_baton's exit callback after it is called so it can be
automatically released, preventing leaked instances.

Adds basic implementation for Pipe's get_status() method and forces PTY
to wait for child process to exit to ensure exit callback is cleaned up.

Adds a test to check that exit callback is still called as usual.
This commit is contained in:
Leroy Hopson 2022-06-23 20:30:27 +07:00
parent 38927e0a3e
commit 0ae1d80abb
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
5 changed files with 24 additions and 4 deletions

View file

@ -96,9 +96,10 @@ func open(cols: int = DEFAULT_COLS, rows: int = DEFAULT_ROWS) -> Array:
func _exit_tree():
_exit_cb = null
if _pid > 1:
LibuvUtils.kill(_pid, Signal.SIGHUP)
while _pipe.get_status() != 0:
continue
func _on_pipe_data_received(data):