[comp.mail.elm] Fix for ^Z problems

lmb@vicom.COM (Larry Blair) (12/31/88)

Due to its Sys V origins, elm doesn't properly deal with stop signals in
child tasks, such as the editor or external pager.  Enclosed are patches
to fix those two cases.  There is a third case, when checking for access
to the file to be read, that I didn't fix since I didn't want to change
the vfork to a fork.

It seems to me that there has got to a better way a temporarily assuming
the real uid and gid than forking a new task, but that's a subject for
unix.wizards.

*** syscall.c.old	Fri Dec 30 14:38:31 1988
--- syscall.c	Fri Dec 30 14:44:05 1988
***************
*** 106,111 ****
--- 106,114 ----
  #else
  	int status;
  #endif
+ #ifdef SIGTSTP
+ 	int (*oldstop)(), (*oldstart)();
+ #endif
  	register int (*istat)(), (*qstat)();
  	
  	dprint(2, (debugfile,
***************
*** 112,117 ****
--- 115,124 ----
  		"System Call: %s\n\t%s\n", shell_type == SH? "/bin/sh" : shell,
  		string));
  
+ #ifdef SIGTSTP
+ 	oldstop = signal(SIGTSTP, SIG_DFL);
+ 	oldstart = signal(SIGCONT, SIG_DFL);
+ #endif
  #ifdef NO_VM		/* machine without virtual memory! */
  	if ((pid = fork()) == 0) {
  #else
***************
*** 140,145 ****
--- 147,156 ----
  	if (status.w_retcode != 0) stat = status.w_retcode;
  #else
  	if (w == -1) stat = status;
+ #endif
+ #ifdef SIGTSTP
+ 	signal(SIGTSTP, oldstop);
+ 	signal(SIGCONT, oldstart);
  #endif
  	
  	signal(SIGINT, istat);
*** showmsg.c.old	Tue Dec 27 17:37:25 1988
--- showmsg.c	Fri Dec 30 15:40:26 1988
***************
*** 519,524 ****
--- 519,530 ----
  	int status;
  #endif
  	register int (*istat)(), (*qstat)();
+ #ifdef SIGTSTP
+ 	register int (*oldstop)(), (*oldstart)();
+ 
+ 	oldstop = signal(SIGTSTP, SIG_DFL);
+ 	oldstart = signal(SIGCONT, SIG_DFL);
+ #endif
  	
  #ifdef NO_VM		/* machine without virtual memory! */
  	if ((pid = fork()) == 0) {
***************
*** 526,531 ****
--- 532,540 ----
  #  ifdef hp9000s500			/* done this way for portability */
  	if ((pid = fork()) == 0) {
  #  else
+ #  ifdef SIGTSTP	/* Stop won't work over active vfork! */
+ 	if ((pid = fork()) == 0) {
+ #  else
  	if ((pid = vfork()) == 0) {
  #  endif
  #endif
***************
*** 544,549 ****
--- 553,562 ----
  
  	signal(SIGINT, istat);
  	signal(SIGQUIT, qstat);
+ #ifdef SIGTSTP
+ 	signal(SIGTSTP, oldstop);
+ 	signal(SIGCONT, oldstart);
+ #endif
  
  	/** used to return status, but who cares?  Just get BACK! **/
  
-- 
Larry Blair   ames!vsi1!lmb   lmb@vicom.com