Curses doesn't handle ^Z's properly

Ron Wessels wessels at uthub.UUCP
Thu May 3 09:25:03 AEST 1984


Subject: Curses catches SIGTSTP regardless of previous state
Index:	usr.lib/libcurses/initscr.c 4.2BSD

Description:
	The curses library insists on catching ^Z (SIGTSTP) even if
	it is being ignored or has another signal handler.  This is
	particularly painful if you happen to use /bin/sh as your
	login shell and run with the new tty driver.  Also, if you
	want to catch ^Z's yourself, you have to be careful to
	signal(SIGTSTP,handler) AFTER the initscr() call, or curses
	will reset it.
Repeat-By:
	Change your login shell to be /bin/sh.  Run
		$ stty new
		$ talk `whoami`
	and hit ^Z.  Bingo, your process has been SIGTSTP'ed.  Of
	course, /bin/sh doesn't know about this, so you're hung in
	limbo.  Time to find another terminal and kill the talk
	process.
Fix:
	*** /tmp/,RCSt1006002	Thu Apr 26 21:28:07 1984
	--- initscr.c	Thu Apr 26 21:17:35 1984
	***************
	*** 13,18
	  initscr() {
	  
		reg char	*sp;
		int		tstp();
	  
	  # ifdef DEBUG

	--- 13,19 -----
	  initscr() {
	  
		reg char	*sp;
	+ 	int		(*oldtstp)();
		int		tstp();
	  
	  # ifdef DEBUG
	***************
	*** 39,45
		_puts(TI);
		_puts(VS);
	  # ifdef SIGTSTP
	! 	signal(SIGTSTP, tstp);
	  # endif
		if (curscr != NULL) {
	  # ifdef DEBUG

	--- 40,47 -----
		_puts(TI);
		_puts(VS);
	  # ifdef SIGTSTP
	! 	if ((oldtstp = signal(SIGTSTP, tstp)) != SIG_DFL)
	! 		(void) signal(SIGTSTP, oldtstp);
	  # endif
		if (curscr != NULL) {
	  # ifdef DEBUG

Of course, you now should recompile every program that uses -lcurses.

-- 
Ron Wessels	Computer Systems Research Group		University of Toronto
{ decvax , floyd , ihnp4 , linus , utzoo , uw-beaver }!utcsrgv!uthub!wessels



More information about the Comp.unix.wizards mailing list