chris@umcp-cs.UUCP (08/09/83)
Ok, I've received enough requests that I'm just going to post these. The only change is to support /bin/sh logins, where SIGTSTP is set to SIG_IGN. This bit of info is kept in the variable "WIgnoreTSTP" and is checked during init and cleanup. No changes to suspend.c are needed since the signal is ignored. Admittedly it's unesthetic to redraw the screen, but if you're using /bin/sh you probably don't have a TSTP key anyway. The version number in open.c is now 1.06. - Chris : Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ]; then all=TRUE fi /bin/echo 'Please change the version number in open.c to 1.06.' /bin/echo /bin/echo 'Extracting init.c' sed 's/^X//' <<'//go.sysin dd *' >init.c X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X/* Original code copyright (c) 1981,1980 James Gosling */ X/* ACT 11-Nov-1982 modified for window package */ X/* ACT 14-Jul-1983 changed to default to homing cursor */ X/* ACT 1-Aug-1983 compatibility for /bin/sh: WIgnoreTSTP */ #include "win.h" #include "display.h" #include <sys/ioctl.h> #include <sgtty.h> #include <stdio.h> #include <signal.h> struct sgttyb WOld; /* The initial tty mode bits */ int WTtyFd; /* File descriptor for stty/gtty */ int WIgnoreTSTP; /* Set if SIGTSTP is SIG_IGN */ int (*sigset())(); extern Wexit (), Wsuspend (); X/* Init window system. If settings == 1, use previous settings. If settings == 0, use default settings. Otherwise use "settings" settings. If nomagic != 0, don't catch stop, interrupt, and terminate signals. RETURNS: 0 if OK to continue using window system, anything else to indicate that the CRT is unusable. */ Winit (settings, nomagic) struct sgttyb *settings; { static struct sgttyb sg; int rv; static int beenhere; extern char _sobuf[]; WTtyFd = 0; /* I dont know how system specific this is, but here goes: */ if ((stdout->_flag & (_IOLBF|_IONBF)) == 0 && stdout->_base == NULL) setbuf (stdout, _sobuf); /* I should use isatty, but it just does a gtty anyway, so why bother? */ /* Note: if both of these fail then "we ain't talkin' to no terminal" */ /* NOTE: STRUCTURE ASSIGNMENT */ if (gtty (0, &WOld) < 0) gtty (WTtyFd = 1, &WOld); if (settings) { if (settings != (struct sgttyb *) 1) sg = *settings; sg.sg_ispeed = WOld.sg_ispeed;/* My, how suspicious we are */ sg.sg_ospeed = WOld.sg_ospeed; } else sg = WOld; sg.sg_flags = (sg.sg_flags & ~(ECHO | CRMOD | XTABS)) | CBREAK; ioctl (WTtyFd, TIOCSETN, &sg); if (!nomagic /*|| SigMagic*/) { SigMagic = 1; sigset (SIGINT, Wexit); WIgnoreTSTP = sigset (SIGTSTP, Wsuspend) == SIG_IGN; sigset (SIGTERM, Wexit); } ScreenGarbaged = 1; /* I wish I didn't have to set everything up yet, but since WDterm_init() expects to be in un-user-usable mode I have to. Oh well. */ /* NOTE: WDterm_init () may only fail on first attempts! */ if (rv = WDterm_init ()) { /* Then we cant run on this terminal */ if (SigMagic) { /* Wonder if this is really necessary? */ sigignore (SIGTSTP); sigignore (SIGINT); } ioctl (WTtyFd, TIOCSETN, &WOld); if (SigMagic) { if (!WIgnoreTSTP) sigset (SIGTSTP, SIG_DFL); sigset (SIGINT, SIG_DFL); } return rv; } if (W_tt.t_window) (*W_tt.t_window) (0); WindowsActive++; if (!beenhere) { /* New!! (Be the first on your block!) */ beenhere++; if (!WSetRealCursor && !WRCurRow && !WRCurCol) WSetRealCursor++; /* Default to homing the cursor. The idea here is to get that nasty real cursor out of the way. */ } return 0; } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 init.c /bin/echo -n ' '; /bin/ls -ld init.c fi /bin/echo 'Extracting cleanup.c' sed 's/^X//' <<'//go.sysin dd *' >cleanup.c X/* Initialize, suspend, resume, and exit routines */ X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X/* Original code copyright (c) 1981,1980 James Gosling */ X/* ACT 11-Nov-1982 modified for window package */ #include "win.h" #include "display.h" #include <sys/ioctl.h> #include <sgtty.h> #include <stdio.h> #include <signal.h> extern struct sgttyb WOld; /* The initial tty mode bits */ extern WTtyFd; /* File descriptor for stty/gtty */ extern WIgnoreTSTP; /* True => ignore SIGTSTP */ int (*sigset())(); extern Wexit (), Wsuspend (); Wcleanup () { if (SigMagic) { sigignore (SIGTSTP); sigignore (SIGINT); } if (W_tt.t_window) (*W_tt.t_window) (0); (*W_tt.t_topos) (ScreenLength, 1); (*W_tt.t_wipeline) (0, ScreenWidth); (*W_tt.t_cleanup) (); fflush (stdout); ioctl (WTtyFd, TIOCSETN, &WOld); if (SigMagic) { if (!WIgnoreTSTP) sigset (SIGTSTP, SIG_DFL); sigset (SIGINT, SIG_DFL); } WindowsActive = 0; return 0; } //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 cleanup.c /bin/echo -n ' '; /bin/ls -ld cleanup.c fi -- In-Real-Life: Chris Torek, Univ of MD Comp Sci UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris.umcp-cs@UDel-Relay