diff options
author | midipix <writeonce@midipix.org> | 2016-07-22 01:22:22 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-07-24 06:15:21 -0400 |
commit | 48271e3845cb119414f9b82a11a0404261efdb1d (patch) | |
tree | 0fab7f7f490935afb0665e45bc313bb2e4d874d6 /src | |
parent | c26174a7fb2eb57dd26ac3dd31e987d5199e5bc7 (diff) | |
download | ptycon-48271e3845cb119414f9b82a11a0404261efdb1d.tar.bz2 ptycon-48271e3845cb119414f9b82a11a0404261efdb1d.tar.xz |
debug: added job-control session creation in 'raw' and 'oven' modes.
Diffstat (limited to 'src')
-rw-r--r-- | src/internal/ptycon_ioctl_impl.h | 79 | ||||
-rw-r--r-- | src/pty/ptyc_pty_ctx.c | 5 |
2 files changed, 84 insertions, 0 deletions
diff --git a/src/internal/ptycon_ioctl_impl.h b/src/internal/ptycon_ioctl_impl.h index a3d902d..d87ff3a 100644 --- a/src/internal/ptycon_ioctl_impl.h +++ b/src/internal/ptycon_ioctl_impl.h @@ -67,4 +67,83 @@ static int32_t ptyc_set_client_info( return NT_STATUS_SUCCESS; } +static int32_t ptyc_pty_own( + nt_pty * hpty, + nt_runtime_data * rtdata) +{ + int32_t status; + nt_tty_session_info sessioninfo; + nt_tty_sigctl_info ctlinfo; + nt_pty_client_info ptyinfo; + nt_iosb iosb; + + /* inherited session info */ + if ((status = ntapi->tty_client_session_query( + rtdata->hsession, + &sessioninfo))) + return status; + + /* simulated fork */ + sessioninfo.pid = rtdata->cid_self.process_id; + sessioninfo.pgid = sessioninfo.pgid ? sessioninfo.pgid : -1; + sessioninfo.sid = 0; + sessioninfo.syspid = 0; + + if ((status = ntapi->tty_client_session_set( + rtdata->hsession, + &sessioninfo))) + return status; + + /* setsid() */ + sessioninfo.pid = rtdata->cid_self.process_id; + sessioninfo.pgid = rtdata->cid_self.process_id; + sessioninfo.sid = rtdata->cid_self.process_id; + sessioninfo.syspid = 0; + + if ((status = ntapi->tty_client_session_set( + rtdata->hsession, + &sessioninfo))) + return status; + + /* ctty */ + ntapi->tt_aligned_block_memset( + &ctlinfo,0,sizeof(ctlinfo)); + + if ((status = ntapi->pty_ioctl( + hpty, + 0,0,0, + &iosb, + TTY_TIOCSCTTY, + &ctlinfo,sizeof(ctlinfo), + &ctlinfo,sizeof(ctlinfo)))) + return status; + + /* tcsetpgrp */ + ntapi->tt_aligned_block_memset( + &ctlinfo,0,sizeof(ctlinfo)); + + ctlinfo.ctxarg[0] = rtdata->cid_self.process_id; + + if ((status = ntapi->pty_ioctl( + hpty, + 0,0,0, + &iosb, + TTY_TIOCSPGRP, + &ctlinfo,sizeof(ctlinfo), + &ctlinfo,sizeof(ctlinfo)))) + return status; + + /* [ptycon daemon loop]: ctty signals */ + ntapi->tt_aligned_block_memset( + &ptyinfo,0,sizeof(ptyinfo)); + + if ((status = ntapi->pty_set( + hpty,&iosb, + &ptyinfo,sizeof(ptyinfo), + NT_PTY_CLIENT_INFORMATION))) + return status; + + return NT_STATUS_SUCCESS; +} + #endif diff --git a/src/pty/ptyc_pty_ctx.c b/src/pty/ptyc_pty_ctx.c index 99d8c69..e5245c8 100644 --- a/src/pty/ptyc_pty_ctx.c +++ b/src/pty/ptyc_pty_ctx.c @@ -214,6 +214,11 @@ int ptyc_alloc_pty(struct ptyc_driver_ctx * dctx) return ptyc_set_status( dctx,status); + if (cctx->drvflags & (PTYC_DRIVER_DBG_RAW|PTYC_DRIVER_DBG_OVEN)) + if ((status = ptyc_pty_own(cctx->hpts,ictx->rtdata))) + return ptyc_set_status( + dctx,status); + return ptyc_set_status( dctx,NT_STATUS_SUCCESS); } |