Putting a curses program in the background then in the foreground
David Goodenough
dg at lakart.UUCP
Thu Sep 28 03:20:36 AEST 1989
>From article <4013 at augusta.UUCP>, by rcostell at augusta.UUCP (Roger Costello):
> I have a question concerning putting a curses program in the
> background (with ^Z) and then at a later time putting it in the
> foreground (with fg). I have found that when I put the program
> back into the foreground I am back in cbreakmode and in nonecho
> mode. How do I get the program back into the state it was in
> before sending it to the background?
You need to trap the SIG_TSTP and SIG_CONT signals, and do intelligent
things in the trap subroutines. It should be noted that vi and the likes
generally do this.
> Secondly, when I do bring
> the program to the foreground I have observed that the screen is
> redrawn. How is this being accomplished?
By trapping SIG_CONT and redrawing there.
To show the action of what things vi does when starting and stopping,
try the following:
% stty raw
% vi doofus
# stop the vi with ^Z
% stty -raw
% fg
# stop the vi again
% stty
You'll find you're back in raw mode. When vi first started, it noted the
terminal mode, and every time it stops, it resets to that mode. Hence you
arrive in raw mode after the second stop, rather than -raw mode.
--
dg at lakart.UUCP - David Goodenough +---+
IHS | +-+-+
....... !harvard!xait!lakart!dg +-+-+ |
AKA: dg%lakart.uucp at xait.xerox.com +---+
More information about the Comp.unix.questions
mailing list