From 6db2d72937ec42179f9b07a560e75b49603ced56 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 6 Jan 2017 10:59:06 -0500 Subject: ptyc_console_writer(): detect termination of all pts clients. --- src/console/ptyc_console_poller.c | 8 ++++++-- src/console/ptyc_console_writer.c | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/console/ptyc_console_poller.c b/src/console/ptyc_console_poller.c index 7f63197..7aec73d 100644 --- a/src/console/ptyc_console_poller.c +++ b/src/console/ptyc_console_poller.c @@ -17,6 +17,7 @@ int __stdcall ptyc_console_poller(struct ptyc_driver_ctx_impl * ictx) int32_t status; int32_t iostatus; struct ptyc_term_ctx * tctx; + struct ptyc_driver_ctx * dctx; nt_tty_sigctl_info ctlinfo; void * hwnd; void * hevent; @@ -27,6 +28,7 @@ int __stdcall ptyc_console_poller(struct ptyc_driver_ctx_impl * ictx) int diff; tctx = &ictx->tctx; + dctx = &ictx->ctx; if (!(hwnd = ntcon->get_console_window())) return NT_STATUS_INTERNAL_ERROR; @@ -89,7 +91,9 @@ int __stdcall ptyc_console_poller(struct ptyc_driver_ctx_impl * ictx) &ctlinfo,sizeof(ctlinfo)))) return iostatus; } - } while (status == NT_STATUS_TIMEOUT); + } while ((status == NT_STATUS_TIMEOUT) && (dctx->status == NT_STATUS_SUCCESS)); - return NT_STATUS_INTERNAL_ERROR; + return (dctx->status == NT_STATUS_PIPE_DISCONNECTED) + ? NT_STATUS_SUCCESS + : dctx->status ? dctx->status : status; } diff --git a/src/console/ptyc_console_writer.c b/src/console/ptyc_console_writer.c index 24509f8..bef7ea7 100644 --- a/src/console/ptyc_console_writer.c +++ b/src/console/ptyc_console_writer.c @@ -11,6 +11,7 @@ #include #include "ptycon_driver_impl.h" +#include "ptycon_status_impl.h" static ptyc_term_handler ptyc_screen_handler; static ptyc_term_handler ptyc_ctrl_handler; @@ -59,13 +60,12 @@ int __stdcall ptyc_console_writer(struct ptyc_driver_ctx_impl * ictx) 0,0); if (status == NT_STATUS_PENDING) - status = ntapi->zw_wait_for_single_object( - hwait,NT_SYNC_ALERTABLE,0); + if (!(status = ntapi->zw_wait_for_single_object( + hwait,NT_SYNC_ALERTABLE,0))) + status = iosb.status; - if (status || iosb.status) { - ntapi->zw_close(hwait); - return status ? status : iosb.status; - } + if (status) + return ptyc_set_status(&ictx->ctx,status); /* account for leftover bytes from the previous conversion */ tctx->data.in[0] = uc_params.leftover_bytes; -- cgit v1.2.3