summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/internal/ntapi.c1
-rw-r--r--src/internal/ntapi_fnapi.h1
-rw-r--r--src/pty/ntapi_pty_fd.c109
3 files changed, 111 insertions, 0 deletions
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index 7080089..8ebdf22 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -300,6 +300,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->pty_open = __ntapi_pty_open;
__ntapi->pty_reopen = __ntapi_pty_reopen;
__ntapi->pty_inherit = __ntapi_pty_inherit;
+ __ntapi->pty_inherit_runtime_ctty = __ntapi_pty_inherit_runtime_ctty;
__ntapi->pty_close = __ntapi_pty_close;
__ntapi->pty_read = __ntapi_pty_read;
__ntapi->pty_write = __ntapi_pty_write;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 9db0560..ee291ff 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -188,6 +188,7 @@ ntapi_tty_vms_request __ntapi_tty_vms_request;
ntapi_pty_open __ntapi_pty_open;
ntapi_pty_reopen __ntapi_pty_reopen;
ntapi_pty_inherit __ntapi_pty_inherit;
+ntapi_pty_inherit_runtime_ctty __ntapi_pty_inherit_runtime_ctty;
ntapi_pty_close __ntapi_pty_close;
ntapi_pty_read __ntapi_pty_read;
ntapi_pty_write __ntapi_pty_write;
diff --git a/src/pty/ntapi_pty_fd.c b/src/pty/ntapi_pty_fd.c
index ed97418..3071482 100644
--- a/src/pty/ntapi_pty_fd.c
+++ b/src/pty/ntapi_pty_fd.c
@@ -309,3 +309,112 @@ int32_t __stdcall __ntapi_pty_close(nt_pty * pty)
return __ntapi_pty_free(pty);
}
+
+int32_t __stdcall __ntapi_pty_inherit_runtime_ctty(
+ __in void * hport,
+ __in_out nt_runtime_data * rtdata)
+{
+ int32_t status;
+ nt_pty_client_info client_info;
+
+ if (rtdata->stdin_type == NT_FILE_TYPE_PTY) {
+ client_info.any[0] = rtdata->ptyin[0];
+ client_info.any[1] = rtdata->ptyin[1];
+ client_info.any[2] = rtdata->ptyin[2];
+ client_info.any[3] = rtdata->ptyin[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hstdin,
+ &client_info)))
+ return status;
+ }
+
+ if (rtdata->stdout_type == NT_FILE_TYPE_PTY) {
+ if ((rtdata->stdin_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyout[0] == rtdata->ptyin[0])
+ && (rtdata->ptyout[1] == rtdata->ptyin[1])
+ && (rtdata->ptyout[2] == rtdata->ptyin[2])
+ && (rtdata->ptyout[3] == rtdata->ptyin[3])) {
+ rtdata->hstdout = rtdata->hstdin;
+
+ } else {
+ client_info.any[0] = rtdata->ptyout[0];
+ client_info.any[1] = rtdata->ptyout[1];
+ client_info.any[2] = rtdata->ptyout[2];
+ client_info.any[3] = rtdata->ptyout[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hstdout,
+ &client_info)))
+ return status;
+ }
+ }
+
+ if (rtdata->stderr_type == NT_FILE_TYPE_PTY) {
+ if ((rtdata->stdin_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyerr[0] == rtdata->ptyin[0])
+ && (rtdata->ptyerr[1] == rtdata->ptyin[1])
+ && (rtdata->ptyerr[2] == rtdata->ptyin[2])
+ && (rtdata->ptyerr[3] == rtdata->ptyin[3])) {
+ rtdata->hstderr = rtdata->hstdin;
+
+ } else if ((rtdata->stdout_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyerr[0] == rtdata->ptyout[0])
+ && (rtdata->ptyerr[1] == rtdata->ptyout[1])
+ && (rtdata->ptyerr[2] == rtdata->ptyout[2])
+ && (rtdata->ptyerr[3] == rtdata->ptyout[3])) {
+ rtdata->hstderr = rtdata->hstdout;
+
+ } else {
+ client_info.any[0] = rtdata->ptyerr[0];
+ client_info.any[1] = rtdata->ptyerr[1];
+ client_info.any[2] = rtdata->ptyerr[2];
+ client_info.any[3] = rtdata->ptyerr[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hstderr,
+ &client_info)))
+ return status;
+ }
+ }
+
+ /* hctty */
+ if ((rtdata->stdin_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyctl[0] == rtdata->ptyin[0])
+ && (rtdata->ptyctl[1] == rtdata->ptyin[1])
+ && (rtdata->ptyctl[2] == rtdata->ptyin[2])
+ && (rtdata->ptyctl[3] == rtdata->ptyin[3])) {
+ rtdata->hctty = rtdata->hstdin;
+
+ } else if ((rtdata->stdout_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyctl[0] == rtdata->ptyout[0])
+ && (rtdata->ptyctl[1] == rtdata->ptyout[1])
+ && (rtdata->ptyctl[2] == rtdata->ptyout[2])
+ && (rtdata->ptyctl[3] == rtdata->ptyout[3])) {
+ rtdata->hctty = rtdata->hstdout;
+
+ } else if ((rtdata->stderr_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyctl[0] == rtdata->ptyerr[0])
+ && (rtdata->ptyctl[1] == rtdata->ptyerr[1])
+ && (rtdata->ptyctl[2] == rtdata->ptyerr[2])
+ && (rtdata->ptyctl[3] == rtdata->ptyerr[3])) {
+ rtdata->hctty = rtdata->hstderr;
+
+ } else {
+ client_info.any[0] = rtdata->ptyctl[0];
+ client_info.any[1] = rtdata->ptyctl[1];
+ client_info.any[2] = rtdata->ptyctl[2];
+ client_info.any[3] = rtdata->ptyctl[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hctty,
+ &client_info)))
+ rtdata->hctty = 0;
+ }
+
+ return NT_STATUS_SUCCESS;
+}