Initial checkin of a program which starts a sub-pty and filters the
incoming and outgoing data. Could be used to do `luit'-type stuff,
or perhaps other things. Initial plan is to use it to work round the
xterm problems with bold + reverse + bold-as-colour all at once.


git-svn-id: svn://svn.tartarus.org/sgt@1880 cda61777-01e9-0310-a592-d414129be87e
setsid() was the missing call that makes job control and signals work.


git-svn-id: svn://svn.tartarus.org/sgt@2014 cda61777-01e9-0310-a592-d414129be87e
Extend this filter framework so that it actually does something. It
now builds `nullfilter', which does nothing and acts as a starting
point for writing future filters, and `csfilter' which makes use of
libcharset to do the same job as luit.


git-svn-id: svn://svn.tartarus.org/sgt@4229 cda61777-01e9-0310-a592-d414129be87e
Of course, I do actually _have_ charset_from_locale(), and if I use
it then csfilter works almost exactly like luit. Neat.


git-svn-id: svn://svn.tartarus.org/sgt@4230 cda61777-01e9-0310-a592-d414129be87e
Introducing `nhfilter', a filter which converts ESC+ASCIIalphabetic
into the same alphabetic with the high bit set. Useful in NetHack,
because that supports high-bit-meta but not esc-prefix-meta.

This also required an infrastructure change to allow a translator
backend to request a timer after processing some input; if the timer
times out with no further input being received the translator will
be called back with an empty buffer. This means that if you just
press ESC, nhfilter can decide after a while that you're not going
to give it a following character at all, and just send the ESC on
unmodified.


git-svn-id: svn://svn.tartarus.org/sgt@6495 cda61777-01e9-0310-a592-d414129be87e
Added `record', a filter utility which re-implements both `script'
and `ttyrec', mostly because both of those tools have a really
stupid syntax for specifying the command to run inside the pty. In
order to implement this filter I've had to add infrastructure to the
general code base: a function for handling per-filter command line
_options_ (arguments were already supported), plus functions for
setup and tear-down.


git-svn-id: svn://svn.tartarus.org/sgt@6540 cda61777-01e9-0310-a592-d414129be87e
New filter program: `idlewrapper', which times out a program if no
activity appears on its stdin or stdout for a given timeout period.
In order to implement this I've had to introduce another small
infrastructure change: tstate_ready() can now set initial input and
output timeouts. Also I've added a global `-p' option which causes
any of these wrappers to spawn their subprocess in a pair of pipes
rather than in a pty.


git-svn-id: svn://svn.tartarus.org/sgt@6674 cda61777-01e9-0310-a592-d414129be87e
Don't forget to close the master fds before waiting for child
process termination, otherwise the child process might very well
never terminate!


git-svn-id: svn://svn.tartarus.org/sgt@6675 cda61777-01e9-0310-a592-d414129be87e
Missing #includes.


git-svn-id: svn://svn.tartarus.org/sgt@6676 cda61777-01e9-0310-a592-d414129be87e
Rework the main program for these filters so that it does
simultaneous select() between its input _and_ output fds. It should
now never deadlock.


git-svn-id: svn://svn.tartarus.org/sgt@6680 cda61777-01e9-0310-a592-d414129be87e
Replicate winsize and termios from outer into inner terminal.


git-svn-id: svn://svn.tartarus.org/sgt@7469 cda61777-01e9-0310-a592-d414129be87e
One "select: Interrupted system call" error is one too many. Guard
against EINTR from select() being treated as a real error.


git-svn-id: svn://svn.tartarus.org/sgt@8001 cda61777-01e9-0310-a592-d414129be87e
Use the pipe strategy for signal handling (so that signals turn into
bytes written on an intra-process pipe and come out in the main
select loop). Also introduce the new global -q option, which makes
the filter main loop eager to find the first excuse to quit rather
than waiting until the last reason to stay open has disappeared.


git-svn-id: svn://svn.tartarus.org/sgt@8012 cda61777-01e9-0310-a592-d414129be87e
Oops, rogue diagnostic left in.


git-svn-id: svn://svn.tartarus.org/sgt@8013 cda61777-01e9-0310-a592-d414129be87e
Explicitly clear and reset our child process's controlling terminal.
Without this, it appears to get set automatically when the child
process spawns _another_ process (e.g. if the main child process is
a shell), but causes trouble if the top-level child is e.g. ssh.

(The Makefile change in this revision was accidentally committed,
and properly belongs in r8206. Oops.)


git-svn-id: svn://svn.tartarus.org/sgt@8205 cda61777-01e9-0310-a592-d414129be87e
A near-trivial filter which implements cheaty anti-idle-out measures
in a fairly generic sense. Corresponding makefile change was
accidentally committed as part of r8205.


git-svn-id: svn://svn.tartarus.org/sgt@8206 cda61777-01e9-0310-a592-d414129be87e
When I switched over to the pipe strategy for signal handling in
r8012, it turns out I did a somewhat half-hearted job. The variables
'exitcode' and 'childpid' no longer need to be global, since the
signal handler doesn't need to access them (and for the same reason,
exitcode no longer needs to be a sig_atomic_t). More to the point, I
should have moved the call to signal() to set up the SIGCHLD handler
to _before_ the fork, eliminating a race condition if the child
process terminates before the parent has set up its handler. I think
this should fix the intermittent hangs I've been seeing on my
nightly calendar batch job which uses nullfilter.


git-svn-id: svn://svn.tartarus.org/sgt@8760 cda61777-01e9-0310-a592-d414129be87e
Invent a method of signalling EOF to translation modules, so they can
append a last parting comment to the translated data.


git-svn-id: svn://svn.tartarus.org/sgt@9301 cda61777-01e9-0310-a592-d414129be87e
Use the new EV_EOF mechanism to implement an '-e' option to csfilter,
which makes it output escape sequences at the start and end of the
output to configure the terminal into an appropriate mode. Currently
the only outer charset supported by this feature is UTF-8, for which
it sends ESC % G and ESC % @ to start and stop UTF-8 mode in a
terminal defaulting to something else. So now I can temporarily put
one of my ordinary pterms (which default to ISO 8859-1) into some
other charset simply by saying 'csfilter -e whatever'.


git-svn-id: svn://svn.tartarus.org/sgt@9302 cda61777-01e9-0310-a592-d414129be87e
When in pty mode, catch SIGWINCH on the outer terminal and pass window
size changes through to the inner one. How have I not thought to do
that before?!


git-svn-id: svn://svn.tartarus.org/sgt@9541 cda61777-01e9-0310-a592-d414129be87e