alloca (was: libpw.a)
Leslie Mikesell
les at chinet.chi.il.us
Tue May 2 15:02:22 AEST 1989
In article <10177 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>>longjmp is evil.
>Well, at least it's worse than "goto".
>Some people have found reasonable (albeit obscure) uses for longjmp.
>I don't use it myself.
Here is a use:
A print spooler output process accepts commands to print files on a
pipe from its parent (the scheduler). An interactive control program
can cause the scheduler to send signals to the output process. One
signal causes the current job to be restarted from the beginning,
another causes the current job to be discarded and the next command to
be read from the input pipe. There are many sub-functions involved
in the output process. Using longjmp() out of the signal handler
allows rapid response from anywhere in the program doing only the
clean-up needed for the current state.
Is there any other way to handle a situation like this? Testing a
global variable set in the signal handler at all the appropriate
places would add quite a bit of overhead.
Les Mikesell
More information about the Comp.unix.wizards
mailing list