Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site axiom.UUCP Path: utzoo!linus!axiom!smk From: smk@axiom.UUCP (Steven M. Kramer) Newsgroups: net.bugs.4bsd,net.unix-wizards Subject: Re: A few small bugs in 4.2bsd learn... Message-ID: <491@axiom.UUCP> Date: Sun, 19-Feb-84 14:55:27 EST Article-I.D.: axiom.491 Posted: Sun Feb 19 14:55:27 1984 Date-Received: Sun, 19-Feb-84 20:14:54 EST References: <215@rna.UUCP> Organization: Axiom Technology, Newton MA Lines: 146 And there is another bug ... The tty is not reset after the session in learn is over. For the files lesson, the /usr/src/usr.lib/learn/files/Init file contains a stty which is not undone by learn itself upon wrapup. The fix is to simply save the terminal state before executing Init and then restore it upon wrapup. --steve kramer diff -c follows on learn.c and wrapup.c: ----------- *** learn.c.orig Thu Jan 19 11:39:28 1984 --- learn.c Thu Jan 19 11:40:59 1984 *************** *** 5,10 #include "stdio.h" #include "lrnref.h" #include "signal.h" char *direct = "/usr/lib/learn"; /* CHANGE THIS ON YOUR SYSTEM */ int more; --- 5,16 ----- #include "stdio.h" #include "lrnref.h" #include "signal.h" + #ifdef AXIOM + /* For saving the terminal state before entering learn and then + restoring if upon exiting. + */ + #include "sgtty.h" + #endif char *direct = "/usr/lib/learn"; /* CHANGE THIS ON YOUR SYSTEM */ int more; *************** *** 27,32 int skip; int teed; int total; main(argc,argv) int argc; --- 33,48 ----- int skip; int teed; int total; + #ifdef AXIOM + /* + * Fixes a bug whereby the learn program leaves you in a stty state + * fixed by whaever program you were running. We use this sgttyb + * to save the state upon entering learn. The corresponsing reset + * code is in wrapup() in wrapup.c + * Steve Kramer 1/20/84 + */ + struct sgttyb save_terminal_state; + #endif main(argc,argv) int argc; *************** *** 36,41 extern char * getlogin(); char *malloc(); speed = 0; more = 1; pwline = getlogin(); --- 52,60 ----- extern char * getlogin(); char *malloc(); + #ifdef AXIOM + gtty (fileno (stdin), &save_terminal_state); + #endif speed = 0; more = 1; pwline = getlogin(); *** wrapup.c.orig Tue Apr 26 03:04:34 1983 --- wrapup.c Thu Jan 19 11:59:10 1984 *************** *** 5,10 #include "signal.h" #include "stdio.h" #include "lrnref.h" wrapup(n) int n; --- 5,13 ----- #include "signal.h" #include "stdio.h" #include "lrnref.h" + #ifdef AXIOM + /* For restoring the terminal state when leaving. */ + #include "sgtty.h" extern struct sgttyb save_terminal_state; #endif *************** *** 6,11 #include "stdio.h" #include "lrnref.h" wrapup(n) int n; { --- 9,17 ----- /* For restoring the terminal state when leaving. */ #include "sgtty.h" + extern struct sgttyb save_terminal_state; + #endif + wrapup(n) int n; { *************** *** 30,35 } if (!n && todo) printf("To take up where you left off type \"learn %s %s\".\n", sname, todo); printf("Bye.\n"); /* not only does this reassure user but it stalls for time while deleting directory */ fflush(stdout); --- 36,48 ----- } if (!n && todo) printf("To take up where you left off type \"learn %s %s\".\n", sname, todo); + #ifdef AXIOM + /* + * Leave the terminal the way we found it! + * Steve Kramer 1/20/84 + */ + stty (fileno (stdin), &save_terminal_state); + #endif printf("Bye.\n"); /* not only does this reassure user but it stalls for time while deleting directory */ fflush(stdout); -- --steve kramer {allegra,genrad,ihnp4,utzoo,philabs,uw-beaver}!linus!axiom!smk (UUCP) linus!axiom!smk@mitre-bedford (MIL)