brown@cs.rochester.edu (Chris Brown) (10/16/87)
How can one escape from an infinitely recursive ksh function, such as foo () { foo ; } My experience (blush) is that shift-esc and ctrl-shift-pipe work fine, in that the process hesitates, and in the second case core is dumped, but like Jason, or that guy in Halloween, the thing just keeps coming back, executing forever. 1. if one is in unix thru ua, then (I presume) one could get to another window, su root and kill the runaway shell script. 2. but what if one isn't in ua? I don't plan to do this sort of thing often, but hitting the reset button is more embarrassing than this posting. Thanks! Chris Brown
ken@maxepr.UUCP (Ken Brassler) (10/16/87)
In article <3269@sol.ARPA> brown@cs.rochester.edu (Chris Brown) writes: >How can one escape from an infinitely recursive ksh function... >..... if one isn't in ua? Easy - create a second (or more) virtual terminal that you can switch to via the suspd key. First, ignore all warnings that you shouldn't do this, then edit /etc/inittab and add a line which spawns another login shell. Here is a fragment from my inittab: : REPEAT: DO NOT EDIT THIS FILE!!! IT IS PROGRAM-MODIFIED!!!!! is:2:initdefault: vid:2:respawn:/etc/getty window 9600 vi1:2:respawn:/etc/getty window 9600 Add this last line, indented one space as shown. Note that it is named 'vi1', not 'vid'. ( you need some unique name) You can add more lines labeled vi2, vi3 etc, for more virtual terminals, limited by the number of window drivers available, but 2 or 3 total is plenty. Then do "telinit q", which tells init to re-examine this file. Virtual terminals have many more uses than just killing a runaway process - try it, you'll like it. Just hit the suspd key to get the window select menu. If you are a UA person, you don't need to do this, and it might screw things up. However, I have 3 virtual terminals, with the UA running in one of them, which is a convenient way to use the UA on occasion. -- Ken Brassler {ihnp4|qantel|pyramid|lll-crg}!ptsfa!maxepr!ken ....ethos!gladys!ptsfa!maxepr!ken
rjd@tiger.UUCP (10/17/87)
> How can one escape from an infinitely recursive ksh function, such as > foo () { foo ; } > > My experience (blush) is that shift-esc and ctrl-shift-pipe work fine, > in that the process hesitates, and in the second case core is dumped, > but like Jason, or that guy in Halloween, the thing just keeps coming > back, executing forever. > > 1. if one is in unix thru ua, then (I presume) one could get to another > window, su root and kill the runaway shell script. > > 2. but what if one isn't in ua? I guess I am missing something, because every Unix system I know of limits a user to a number of process (such as 20). After the 20th iteration of this recursive'ness, you should get an error saying something on the order of "cannot fork".... (since each recursion will spawn a new process). Randy
tel@moby.UUCP (Tom Lowe) (10/20/87)
In article <144800004@tiger.UUCP>, rjd@tiger.UUCP writes: > > > How can one escape from an infinitely recursive ksh function, such as > > foo () { foo ; } > > > I guess I am missing something, because every Unix system I know of limits > a user to a number of process (such as 20). After the 20th iteration of this > recursive'ness, you should get an error saying something on the order of > "cannot fork".... (since each recursion will spawn a new process). I get "ksh: foo: recursive call" -- Tom Lowe {rutgers,gatech,huscb,burdvax,ihnp4,cbosgd}!psuvax1!moby!tel AT&T National Systems Support Center, S. Plainfield, NJ (1-800-922-0354) Please call only if you have an AT&T computer under Warranty or if you have an AT&T Maintenance Contract on your equipment.
jbm@uncle.UUCP (John B. Milton) (10/21/87)
I have seen several people talking about using multiple login windows through inittab. This method has the obvious problem that you have to login to each to use it. A quicker approach is to use windy from THE STORE! The latest version of windy has a -b switch to execute the given command in the back- ground. In my .profile I have section: ----------- if [ "expr `tty` : '/dev/w'" != 0 ] then windy -n "Login shell" -l "Login shell" windy -b -n "Extra shell" -l "Extra shell" $SHELL fi set -o ignoreeof ----------- The first windy just names the current window for finding with Suspd. The second windy runs a shell in another window, in the background, Named. This way you don't have to login every time. I can see how you might want to have one or two of each; a quicky ksh and a login. For those of you who are windy fans: There is a serious bug in windy. See a following message... -- John Bly Milton IV {ihnp4|cbosgd}!n8emr!uncle!jbm (614)294-4823 (home, where the ATT 7300 [uncle] lives) (614)424-7677 (work, where the HP 9836 lives)
rjd@tiger.UUCP (10/22/87)
> > > How can one escape from an infinitely recursive ksh function, such as > > > foo () { foo ; } > > > > > I guess I am missing something, because every Unix system I know of limits > > a user to a number of process (such as 20). After the 20th iteration of this > > recursive'ness, you should get an error saying something on the order of > > "cannot fork".... (since each recursion will spawn a new process). > > I get "ksh: foo: recursive call" > Sounds like you have already escaped from it then.... So what's the problem? Randy
guy%gorodish@Sun.COM (Guy Harris) (10/23/87)
> I guess I am missing something, because every Unix system I know of limits > a user to a number of process (such as 20). Yes, you're missing something; shell functions are not executed by starting up another process. This means you can write shell functions to do e.g. the C shell's "pushd" and "popd" functions, as any "cd"s done by the function affect the shell to which the "pushd" or "popd" was typed. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com