avr@CS-Mordred (Andrew V Royappa) (08/25/85)
Two requests: 1. Please add me to your mailing list. I was on it, but haven't received anything for a long time. 2. We're running emacs #264 with various modifications, mostly from utah-cs. There's one incredibly annoying bug which keeps cropping up: when emacs exits (normally) it often leaves the loadst process hanging around on the pty it grabbed. Needless to say, when someone else gets that pty via rlogin etc., they get these irritating lines of loadst output on their screen which they can't remedy since the loadst process isn't theirs. Now, I'm sure this bug has been caught and squashed somewhere else, so I'd be very grateful if you (insert hand with index finger pointing out of the screen) would send me the fix, if you know it. Hints and comments, helpful or otherwise, are welcome. I don't know much about the way emacs handles processes under 4.2, so I doubt if I can fix it myself. Thanks, Andrew Royappa avr@purdue.arpa {ihnp4, ucbvax, decvax, pur-ee}!purdue!avr
chris@umcp-cs.UUCP (Chris Torek) (08/27/85)
>... There's one incredibly annoying bug which keeps cropping up: >when emacs exits (normally) it often leaves the loadst process >hanging around on the pty it grabbed. This is (believe it or not) a kernel bug (which I haven't tracked down). The workaround is to use TIOCSPGRP twice, with the second being *after* the TIOCSETD ioctl. I believe (but have not tried) setting it only once, but after doing TIOCSETD, suffices. If you have ever looked at the way TIOCSETD works in the 4.2 kernel, you will understand why I'm not sure where the bug is, and why I have not bothered tracking it down.... -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland
chris@umcp-cs.UUCP (Chris Torek) (08/27/85)
Oops, forgot to include the actual text of my version of the fix. Your code may differ. RCS file: RCS/pchan.c,v retrieving revision 2.10 retrieving revision 2.11 diff -c2 -r2.10 -r2.11 *** /tmp/,RCSt1003600 Tue Aug 27 06:16:54 1985 --- /tmp/,RCSt2003600 Tue Aug 27 06:17:03 1985 *************** *** 235,238 (void) ioctl (0, TIOCSETD, &ld); UseUsersShell = len; sh = shell (); execlp (sh, sh, --- 235,242 ----- (void) ioctl (0, TIOCSETD, &ld); UseUsersShell = len; + /* BEGIN BOGUS KERNEL-BUG-WORKAROUND */ + (void) ioctl (0, TIOCSPGRP, &pgrp); + setpgrp (0, pgrp); + /* END BOGUS KERNEL-BUG-WORKAROUND */ sh = shell (); execlp (sh, sh, *************** *** 239,243 UseUsersShell && UseCshOptionF ? "-cf" : "-c", command, (char *) 0); ! (void) write (1, "Couldn't exec the shell\n", 24); _exit (1); /* NOTREACHED */ --- 243,249 ----- UseUsersShell && UseCshOptionF ? "-cf" : "-c", command, (char *) 0); ! (void) write (1, "Couldn't exec shell\"", 21); ! (void) write (1, sh, strlen (sh)); ! (void) write (1, "\"\n", 2); _exit (1); /* NOTREACHED */ *************** *** 313,317 readloop: - ichans = sel_ichans; ochans = sel_ochans; --- 319,322 ----- readloop: ichans = sel_ichans; ochans = sel_ochans; *************** *** 468,471 } /* Kill off all active processes: done only to exit when user really --- 473,483 ----- } + /* The following is to work around an obscure bug (which *seems* to be in the + kernel but who can tell for sure??) */ + #define DoKill(pid,sig) \ + do { \ + if (killpg (pid, sig)) \ + kill (pid, sig); \ + } while (0) /* Kill off all active processes: done only to exit when user really *************** *** 471,475 /* Kill off all active processes: done only to exit when user really insists. */ - kill_processes () { register struct process_blk *p; --- 483,486 ----- /* Kill off all active processes: done only to exit when user really insists. */ kill_processes () { register struct process_blk *p; *************** *** 479,485 ioctl (p -> p_chan.ch_index, TIOCGPGRP, &p -> p_gid); if (p -> p_gid != -1) ! killpg (p -> p_gid, SIGKILL); ! if (p -> p_pid != -1) ! killpg (p -> p_pid, SIGKILL); } } --- 490,496 ----- ioctl (p -> p_chan.ch_index, TIOCGPGRP, &p -> p_gid); if (p -> p_gid != -1) ! DoKill (p -> p_gid, SIGKILL); ! if (p -> p_pid != -1 && p -> p_pid != p -> p_gid) ! DoKill (p -> p_pid, SIGKILL); } } *************** *** 557,561 #ifndef TTYconnect if (leader != -1) ! killpg (leader, signal); #else not TTYconnect if (leader != -1) --- 568,572 ----- #ifndef TTYconnect if (leader != -1) ! DoKill (leader, signal); #else not TTYconnect if (leader != -1) *************** *** 560,564 #else not TTYconnect if (leader != -1) ! killpg (leader, signal); else if (process -> p_pid == -1 && signal == SIGKILL) { register int bit = 1 << process -> p_chan.ch_index; --- 571,575 ----- #else not TTYconnect if (leader != -1) ! DoKill (leader, signal); else if (process -> p_pid == -1 && signal == SIGKILL) { register int bit = 1 << process -> p_chan.ch_index; *************** *** 563,566 else if (process -> p_pid == -1 && signal == SIGKILL) { register int bit = 1 << process -> p_chan.ch_index; sel_ichans &= ~bit; sel_ochans &= ~bit; --- 574,578 ----- else if (process -> p_pid == -1 && signal == SIGKILL) { register int bit = 1 << process -> p_chan.ch_index; + sel_ichans &= ~bit; sel_ochans &= ~bit; *************** *** 565,569 sel_ichans &= ~bit; sel_ochans &= ~bit; ! close (process -> p_chan.ch_index); sighold (SIGCHLD); process -> p_flag = SIGNALED | CHANGED; --- 577,581 ----- sel_ichans &= ~bit; sel_ochans &= ~bit; ! (void) close (process -> p_chan.ch_index); sighold (SIGCHLD); process -> p_flag = SIGNALED | CHANGED; *************** *** 576,579 } /* Send an EOT to a process. */ --- 588,592 ----- } + #undef DoKill *************** *** 577,580 /* Send an EOT to a process. */ EOTProcess () { --- 590,594 ----- #undef DoKill + /* Send an EOT to a process. */ EOTProcess () { *************** *** 584,588 if ((process = GetBufProc ()) == NULL) { error ("Not a process"); ! return (0); } --- 598,602 ----- if ((process = GetBufProc ()) == NULL) { error ("Not a process"); ! return 0; } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland
thomas@utah-gr.UUCP (Spencer W. Thomas) (08/27/85)
In article <1403@umcp-cs.UUCP> chris@umcp-cs.UUCP (Chris Torek) writes: >>... There's one incredibly annoying bug which keeps cropping up: >>when emacs exits (normally) it often leaves the loadst process >>hanging around on the pty it grabbed. > > I believe (but have not tried) >setting it only once, but after doing TIOCSETD, suffices. I sent our fix for this problem to the original poster. You are right, that you only need it once. Where you need to put it is AFTER the TIOCNOTTY. If you carefully follow the ttyopen code in the kernel, you will see why. In any case, here are context diffs from our source (your line numbers will probably differ). RCS file: RCS/pchan.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** /tmp/,RCSt1022961 Mon Aug 26 14:59:40 1985 --- /tmp/,RCSt2022961 Mon Aug 26 14:59:47 1985 *************** *** 165,171 #endif close (channel); sigrelse (SIGCHLD); - setpgrp (0, getpid ()); sigsys (SIGINT, SIG_DFL); sigsys (SIGQUIT, SIG_DFL); if ((ld = open ("/dev/tty", 2)) >= 0) { --- 165,170 ----- #endif close (channel); sigrelse (SIGCHLD); sigsys (SIGINT, SIG_DFL); sigsys (SIGQUIT, SIG_DFL); if ((ld = open ("/dev/tty", 2)) >= 0) { *************** *** 179,184 } pgrp = getpid(); ioctl (2, TIOCSPGRP, &pgrp); close (0); close (1); dup (2); --- 178,184 ----- } pgrp = getpid(); ioctl (2, TIOCSPGRP, &pgrp); + setpgrp( 0, pgrp ); /* must go after the NOTTY */ close (0); close (1); dup (2); -- =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA) "To feel at home, stay at home. A foreign country is not designed to make [one] comfortable. It's designed to make its own people comfortable." Clifton Fadiman
kim@mips.UUCP (Kim DeVaughn) (08/27/85)
> > Two requests: > > 1. Please add me to your mailing list. I was on it, > but haven't received anything for a long time. The latest mail.lists I have (8/16/85) doesn't show a mail.emacs, or anything similar. If there *is* such a mailing list, I'd like to be added to it also. Thanx n advance, /kim -- UUCP: {decvax,ucbvax,ihnp4}!decwrl!mips!kim DDD: 415-960-1200 USPS: MIPS Computer Systems Inc, 1330 Charleston Rd, Mt View, CA 94043