kiely@lownlab.UUCP (03/11/87)
Subject: rn hangs when stopped and run in the background Index: local/usenet/rn/final.c Description: When "rn" is stopped with "^Z" and then run in the background with "bg", it hangs (and the terminal hangs) when restarted in the foreground with "fg". Repeat-By: Warning: this hangs your terminal so be sure to have another terminal available before trying this. =================================================== [EDITED] Script started on Wed Mar 11 01:03:06 1987 % % rn -D No unread news in subscribed-to newsgroups. To subscribe to a new newsgroup use the g<newsgroup> command. ******** End of newsgroups--what next? [qnp] ^Zstop_catcher Stopped % bg [1] rn -D & % cont_catcher jobs [1] + Stopped (tty output) rn -D % bg [1] rn -D & /* note that "cont_catcher" is not outputted this time */ % jobs [1] Running rn -D % ps PID TT STAT TIME COMMAND 5744 h3 S 0:00 script 5745 h3 S 0:00 script 5746 p0 S 0:02 -h -i (csh) 5747 p0 T 0:02 rn -D % jobs [1] + Running rn -D % fg rn -D /* the terminal hangs at this point */ script done on Wed Mar 11 01:04:50 1987 ======================================= Fix: Under 4.2 BSD, SIGCONT *is* blocked for the duration of the SIGCONT handler. For this application, SIGCONT must be unblocked immediately on entering the handler or any signal that causes the process to stop will cause the process to hang since it cannot be restarted while SIGCONT is blocked. This may or may not be an kernel bug. The way I read the documentation in section 2 of the manual SIGCONT cannot be blocked. The interpretation that SIGCONT cannot be blocked by the user but is blocked for the duration of the SIGCONT handler must be the correct interpretation because that is the way that it works. This has been tested with an Integrated Solutions Optimum 5/10 running 4.2BSD (ISI release 3.05), a VAX 8200 running Ultrix 1.2, and a MicroVaxII running 4.3BSD. Context diff's follow. RCS file: RCS/final.c,v retrieving revision 4.3.1.1 diff -c -r4.3.1.1 final.c *** /tmp/,RCSt1005819 Wed Mar 11 01:24:31 1987 --- final.c Wed Mar 11 01:22:36 1987 *************** *** 205,210 cont_catcher() { sigset(SIGCONT,cont_catcher); savetty(); # ifdef MAILCALL; mailcount = 0; /* force recheck */ --- 211,219 ----- cont_catcher() { sigset(SIGCONT,cont_catcher); + # ifdef BSD42 + sigsetmask(sigblock(0) & ~(1 << (SIGCONT-1))); + # endif /*BSD42*/ savetty(); # ifdef MAILCALL; mailcount = 0; /* force recheck */ ============================================================================ NAME: James P. Kiely USPS: Kiely Laboratories USENET: ...!harvard!lownlab!kiely P.O. Box 624 DOMAIN: kiely@lownlab.harvard.edu Allston, MA 02134-0624 PHONE: +1 617 782 4136 USA