[comp.unix.wizards] Putting a curses program in the background then in the foreground

rcostell@augusta.UUCP (Roger Costello) (09/21/89)

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? Secondly, when I do bring
the program to the foreground I have observed that the screen  is
redrawn. How is this being accomplished?
As to the later question, I am guessing that when the program is
brought to the foreground the  system (somehow knows to) call the
curses refresh routine passing to it curscr. Is this correct? If
so, then perhaps the solution to the first question is to modify
the curses refresh routine such that it checks for curscr as the
parameter and if curscr is the parameter then it resets the  state,
i.e. sets raw mode and echo mode. Sound reasonable? 
Thanks for any  help you may be able to provide. /Roger

brister@td2cad.intel.com (James Brister) (09/22/89)

My guess about this sort of required behaviour is this:

	i) the program catches the SIGTSTP signal. In the handler it reset the
	   terminal characteristics and then sends itself a SIGSTOP.

        ii) the program catches the SIGCONT signal. In the handler it does a
	   refresh of the necessary stuff and then continues.

There's probably a few minor :-) details in there that need to be added. Comments?

James
--
James Brister                                          brister@td2cad.intel.com
Intel Corp.                                      {decwrl,oliveb}!td2cad!brister