From: Derek Fawcus <dfawcus@cisco.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: Add EXTPROC support for LINEMODE
Date: Wed, 16 Jun 2010 16:13:31 +0100 [thread overview]
Message-ID: <20100616151331.GA11824@gpk-lds-007.cisco.com> (raw)
In-Reply-To: <4C17E14F.5090908@symas.com>
On Tue, Jun 15, 2010 at 01:23:43PM -0700, Howard Chu wrote:
>
> Closest thing I've found so far is for HPUX 11i Version 2:
> http://docs.hp.com/en/B2355-90848docs/B2355-90848docs.pdf
>
> TIOCREMOTE This ioctl puts the STREAMS pty in and out of Remote Mode. When
> TIOCSIGNAL This ioctl allows the master process to send a signal to the slave
> <<<<
>
> TIOCREMOTE seems to be the SVR4 analogue to TIOCPKT without any of the useful parts; it doesn't include the prefix
> byte, so it doesn't provide any state change information.
TIOCREMOTE is also supported on BSDs.
A program I've been playing with on and off for a few years uses it (on solaris, FreeBSD, Darwin).
That in combination with turning off all output post processing, and then regularly sampling the
status of the pty for the following generally works:
static int
internal_get_modes (int fd, int *modep)
{
int modes = 0;
if (tcgetattr(fd, &tty_mode) < 0)
return 0;
if (tty_mode.c_lflag & ICANON)
modes |= MODE_CANON;
else if (tty_mode.c_lflag & ISIG)
modes |= MODE_CBREAK;
else
modes |= MODE_RAW;
if (tty_mode.c_lflag & ECHO)
modes |= MODE_ECHO;
if (tty_mode.c_cc[VINTR] != vdisable) modes |= MODE_INTR;
if (tty_mode.c_cc[VQUIT] != vdisable) modes |= MODE_QUIT;
if (tty_mode.c_cc[VSUSP] != vdisable) modes |= MODE_SUSP;
*modep = modes;
return 1;
}
There is obviously a race condition in detecting the change in the above, but usually this
is only an issue when starting/stopping certain curses apps, and can be handled by the various
app redraw command.
Currently for Linux, I disable echo before feeding characters to the pty, then restore it
to its previous state. So REMOTE mode would be useful.
Sending signals to the terminal group is different for BSD/solaris/Linux:
int master_signal_tcpgrp (int master_fd, unsigned signo) // BSD
{
return ioctl(master_fd, TIOCSIG, signo);
}
int master_signal_tcpgrp (int master_fd, unsigned signo) // Linux
{
pid_t tcpgrp;
tcpgrp = tcgetpgrp(master_fd);
if (tcpgrp == -1) {
return -1;
}
return kill(-tcpgrp, signo);
}
int master_signal_tcpgrp (int master_fd, unsigned signo) // SVR4
{
return ioctl(master_fd, TIOCSIGNAL, signo);
}
Now for a notification type packet mode extension, something which provided the
information extracted in the above set of MODE change indications would be useful,
since it would remove the race condition. i.e. a completely different interpretation
of the packet when supplying the control info.
DF
next prev parent reply other threads:[~2010-06-16 15:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-15 18:56 hyc
2010-06-15 19:29 ` Alan Cox
2010-06-15 19:54 ` Howard Chu
2010-06-15 20:23 ` Howard Chu
2010-06-16 15:13 ` Derek Fawcus [this message]
2010-06-17 20:02 ` Howard Chu
2010-06-17 20:49 ` Alan Cox
2010-06-17 21:23 ` Howard Chu
2010-06-17 23:43 ` Howard Chu
2010-06-16 1:15 ` Chris Adams
2010-06-18 19:45 hyc
2010-06-18 22:20 ` Howard Chu
2010-06-22 15:59 ` Howard Chu
2010-06-22 16:03 ` Greg KH
2010-06-22 17:28 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100616151331.GA11824@gpk-lds-007.cisco.com \
--to=dfawcus@cisco.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®