UNIX mAn pAges:pty(7)

PTY(7M) PTY(7M) NAME pty, pts - pseudo terminal driver DESCRIPTION The pty driver provides a device-pair termed a pseudo terminal. A pseudo terminal is a pair of character devices, a master device and a slave device. The slave device provides processes an interface identical to that described in termio(7). However, whereas all other devices which provide the interface described in termio(7) have a hardware device of some sort behind them, the slave device has, instead, another process manipulating it through the master half of the pseudo terminal. That is, anything written on the master device is given to the slave device as input and anything written on the slave device is presented as input on the master device. The following ioctl calls apply only to pseudo terminals: TIOCPKT Enable/disable packet mode. Packet mode is enabled by specifying (by reference) a nonzero parameter and disabled by specifying (by reference) a zero parameter. When applied to the master side of a pseudo terminal, each subsequent read from the terminal will return data written on the slave part of the pseudo terminal preceded by a zero byte (symbolically defined as TIOCPKT_DATA), or a single byte reflecting control status information. In the latter case, the byte is an inclusive-or of zero or more of the bits: TIOCPKT_FLUSHREAD whenever the read queue for the terminal is flushed. TIOCPKT_FLUSHWRITE whenever the write queue for the terminal is flushed. TIOCPKT_STOP whenever output to the terminal is stopped a la ^S. TIOCPKT_START whenever output to the terminal is restarted. TIOCPKT_DOSTOP whenever t_stopc is ^S and t_startc is ^Q. TIOCPKT_NOSTOP whenever the start and stop characters are not ^S/^Q. This mode is used by rlogin(1C) and rlogind(1M) to implement a remote-echoed, locally ^S/^Q flow-controlled remote login with proper back-flushing of output; it can be used by other similar programs. Page 1 PTY(7M) PTY(7M) ALLOCATION The code sequence shown below demonstrates how to allocate pseudo terminals. Pseudo terminals, like all files, must have the correct file permissions to be accessible. The _ _getpty(3) library function takes care of this problem. #include #include /* * Find a pseudo tty to use and open both sides. * filedes[0] receives the master file descriptor while filedes[1] * receives the slave. The master is opened with O_NDELAY as commonly * needed in daemons such as rlogind and telnetd. */ int /* -1 on failure */ findPseudoTTY(int *filedes) { char *line; line = _getpty(&filedes[0], O_RDWR|O_NDELAY, 0600, 0); if (0 == line) return -1; if (0 > (filedes[1] = open(line, O_RDWR))) { (void)close(filedes[0]); return -1; } return 0; } FILES /dev/ptc - master pseudo terminal /dev/tty[qrstuvwxyz][0-99] - slave pseudo terminals /dev/pts - equivalent to /dev/ttyq[0-9] SEE ALSO getpty(3)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值