taylor@hpldat.UUCP (Dave Taylor) (05/05/87)
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