mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-06-16 13:15:32 +02:00
Kill child process and close pty on exit
- Adds kill() method to LibuvUtils. - Adds close() method to Pipe.
This commit is contained in:
parent
55b0a0577d
commit
c81da3820b
10 changed files with 53 additions and 9 deletions
|
@ -31,7 +31,7 @@ void Pipe::_register_methods() {
|
|||
}
|
||||
|
||||
Pipe::Pipe() {}
|
||||
Pipe::~Pipe() {}
|
||||
Pipe::~Pipe() { close(); }
|
||||
|
||||
void Pipe::_init() {}
|
||||
|
||||
|
@ -39,6 +39,8 @@ void _poll_connection();
|
|||
|
||||
void _read_cb(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf);
|
||||
|
||||
void _close_cb(uv_handle_t *handle);
|
||||
|
||||
void _write_cb(uv_write_t *req, int status);
|
||||
|
||||
void _alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf);
|
||||
|
@ -56,6 +58,11 @@ godot_error Pipe::open(int fd, bool ipc = false) {
|
|||
return GODOT_OK;
|
||||
}
|
||||
|
||||
void Pipe::close() {
|
||||
uv_close((uv_handle_t *)&handle, NULL);
|
||||
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
|
||||
}
|
||||
|
||||
godot_error Pipe::write(String p_data) {
|
||||
char *s = p_data.alloc_c_string();
|
||||
ULONG len = strlen(s);
|
||||
|
@ -88,10 +95,10 @@ void _read_cb(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) {
|
|||
switch (nread) {
|
||||
case UV_EOF:
|
||||
// Normal after shell exits.
|
||||
return;
|
||||
case UV_EIO:
|
||||
// Can happen when the process exits.
|
||||
// As long as PTY has caught it, we should be fine.
|
||||
uv_read_stop(handle);
|
||||
return;
|
||||
default:
|
||||
UV_ERR_PRINT(nread);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue