[comp.emacs] Accessing the tty in GNU Emacs

karl@haddock.ISC.COM (Karl Heuer) (01/22/88)

I am running GNU Emacs 18.40.  My system has the ability to reshape the
screen%, using an ioctl().  I have written a program to allow me to do this
from the shell.

I wrote a (reshape-screen) function which takes a new screen size as argument.
It calls (set-screen-height) and (set-screen-width) to tell Emacs what's going
on, and reshapes the actual screen by invoking the aforementioned program via
(call-process).

Unfortunately, (call-process) reattaches the standard file descriptors, so the
program's ioctl() fails.  I tried redirecting to /dev/tty, but that doesn't
work either because (call-process) calls setpgrp().  My current workaround is
to use a front-end to emacs that dups onto descriptor 9 (it's a shell script:
`exec /usr/local/bin/emacs 9<&0 ${1+"$@"}') and have the function restore from
that descriptor when invoking the program (`"/bin/sh" "-c" "exec ... <&9"').
This is a horrible kludge.

Q1.  Without modifying the C code (using only lisp and shell), is it possible
for a subprocess to access the terminal?

Q2.  Is there any good reason for that setpgrp() to be in there?

Q3.  (If not implied by the answers to the above) what's the best fix?

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
%Well, actually the screen size is fixed, but by switching to a smaller font I
can get more characters.