🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.mail.elm
Article #3720

Patches for BSD job control

#3720
From: Dave Taylor
Date: Tue, 05 May 1987 02:47
214 lines
5412 bytes
From: mkhaw@teknowledge-vaxc.ARPA (Michael Khaw)
Subject: patches for bsd job control
Date: 5 May 87 01:35:43 GMT
Organization: Teknowledge, Inc., Palo Alto CA

I found that the recently posted patches to elm did not handle ctrl-Z/fg
job control correctly for 4bsd; i.e., when you ^Z out of elm, your terminal
is in cooked mode with newline mapping turned OFF, and when you "fg" back,
elm doesn't restore cbreak, noecho mode as it should.  Also, "elmrcfile" as
#define'd in sysdefs.h appears to have an unnecessary leading '/'.

Patches follow for

	src/signals.c
	src/initialize.c
	hdrs/sysdefs.master

Mike Khaw

Apply the following with "patch"

Index: src/signals.c

***************
*** 74,80
  	signal(SIGPIPE, pipe_signal);
  }
  
! #ifdef BSD
  int was_in_raw_state;
  
  sig_user_stop()

--- 74,80 -----
  	signal(SIGPIPE, pipe_signal);
  }
  
! #ifdef SIGTSTP
  int was_in_raw_state;
  
  sig_user_stop()
***************
*** 82,88
  	/* This is called when the user presses a ^Z to stop the
  	   process within BSD 
  	*/
- 	int sig_user_stop;
  
  	was_in_raw_state = RawState();
  

--- 82,87 -----
  	/* This is called when the user presses a ^Z to stop the
  	   process within BSD 
  	*/
  
  	if (signal(SIGTSTP, SIG_DFL) != SIG_DFL)
  	  {
***************
*** 84,98
  	*/
  	int sig_user_stop;
  
! 	was_in_raw_state = RawState();
! 
! 	Raw(OFF);	/* turn it off regardless */
! 
! 	printf("\n\nStopped.  Use \"fg\" to return to Elm\n\n");
! 
! 	signal(SIGTSTP, sig_user_stop);
! 
! 	kill(getpid(), SIGSTOP);
  }
  
  sig_return_from_user_stop()

--- 83,95 -----
  	   process within BSD 
  	*/
  
! 	if (signal(SIGTSTP, SIG_DFL) != SIG_DFL)
! 	  {
! 		signal(SIGTSTP, SIG_DFL);
! 		was_in_raw_state = RawState();
! 	  }
! 	Raw(OFF);	/** restore parent's tty modes **/
! 	kill(0, SIGTSTP);
  }
  
  sig_return_from_user_stop()
***************
*** 99,105
  {
  	/** this is called when returning from a ^Z stop **/
  
! 	int sig_return_from_user_stop();
  
  	printf(
  	 "\nBack in Elm.  (you might need to explicitly request a redraw)\n\n");

--- 96,102 -----
  {
  	/** this is called when returning from a ^Z stop **/
  
! 	int sig_user_stop();
  
  	if (signal(SIGTSTP, sig_user_stop) == SIG_DFL)
  		signal(SIGTSTP, sig_user_stop);
***************
*** 101,106
  
  	int sig_return_from_user_stop();
  
  	printf(
  	 "\nBack in Elm.  (you might need to explicitly request a redraw)\n\n");
  

--- 98,106 -----
  
  	int sig_user_stop();
  
+ 	if (signal(SIGTSTP, sig_user_stop) == SIG_DFL)
+ 		signal(SIGTSTP, sig_user_stop);
+ 
  	printf(
  	 "\nBack in Elm.  (you might need to explicitly request a redraw)\n\n");
  
***************
*** 106,112
  
  	if (was_in_raw_state)
  	  Raw(ON);
- 
- 	signal(SIGCONT, sig_return_from_user_stop);
  }
  #endif

--- 106,110 -----
  
  	if (was_in_raw_state)
  	  Raw(ON);
  }
  #endif

Index: src/initialize.c

***************
*** 51,56
  	int      quit_signal(), term_signal(), ill_signal(),
  		 fpe_signal(),  bus_signal(),  segv_signal(),
  	         alarm_signal(), pipe_signal();
  	char     buffer[SLEN], *cp;
  	
  	userid  = getuid();

--- 51,60 -----
  	int      quit_signal(), term_signal(), ill_signal(),
  		 fpe_signal(),  bus_signal(),  segv_signal(),
  	         alarm_signal(), pipe_signal();
+ #ifdef SIGTSTP
+ 	int	sig_user_stop();
+ 	int	sig_return_from_user_stop();
+ #endif
  	char     buffer[SLEN], *cp;
  	
  	userid  = getuid();
***************
*** 104,109
  	
  	signal(SIGALRM, alarm_signal);		/* Process Timer Alarm	    */
  	signal(SIGPIPE, pipe_signal);		/* Illegal Pipe Operation   */
  
  	get_term_chars();
  	

--- 108,117 -----
  	
  	signal(SIGALRM, alarm_signal);		/* Process Timer Alarm	    */
  	signal(SIGPIPE, pipe_signal);		/* Illegal Pipe Operation   */
+ #ifdef SIGTSTP
+ 	signal(SIGTSTP, sig_user_stop);		/* Suspend signal from tty  */
+ 	signal(SIGCONT, sig_return_from_user_stop); /* Process Cont. signal */
+ #endif
  
  	get_term_chars();
  	

Index: hdrs/sysdefs.master

***************
*** 224,230
  
  #define ELMRC_INFO	"/usr/local/lib/elmrc-info"
  
! #define elmrcfile	"/.elmrc"
  #define mailheaders	".elmheaders"
  #define dead_letter	"Cancelled.mail"
  

--- 224,230 -----
  
  #define ELMRC_INFO	"/usr/local/lib/elmrc-info"
  
! #define elmrcfile	".elmrc"
  #define mailheaders	".elmheaders"
  #define dead_letter	"Cancelled.mail"
  

End of job control patches
-- 
internet:  mkhaw@teknowledge-vaxc.arpa
usenet:	   {hplabs|sun|ucbvax|decwrl|sri-unix}!mkhaw%teknowledge-vaxc.arpa
USnail:	   Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303
Technical Details
Message-ID: <1726@hplabsc.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!styx!ames!ucbcad!ucbvax!hplabs!hplabsc!daemon

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!styx!ames!ucbcad!ucbvax!hplabs!hplabsc!daemon
From: taylor@hpldat.UUCP (Dave Taylor)
Newsgroups: comp.mail.elm
Subject: Patches for BSD job control
Message-ID: <1726@hplabsc.HP.COM>
Date: Mon, 4-May-87 22:47:27 EDT
Article-I.D.: hplabsc.1726
Posted: Mon May  4 22:47:27 1987
Date-Received: Wed, 6-May-87 00:44:13 EDT
Sender: daemon@hplabsc.HP.COM
Reply-To: taylor@hpldat (Dave Taylor)
Organization: Hewlett-Packard Laboratories, Interface Technologies Group
Lines: 214
Approved: taylor@hplabs (with 'postmail')