Is there a way not to use global variables for signal,setjmp,lonjmp?

Chuck Karish karish at mindcrf.UUCP
Mon Sep 17 16:33:02 AEST 1990


In article <119 at wookie.dbaccess.com> ivan at dbaccess.com
(Ivan Covdy) writes:
>In:
>    signal( SignalValue, ActionFunction );
>the function ActionFunction can be defined only as:
>    void ActionFunction( int );   i.e., it can have only one argument.

>What should I do if I want to have such ActionFunction, which changes
>variables, and these variables should not be global/external/static?
>Are there any ways to pass more arguments to ActionFunction?

No.  The user process doesn't pass ANY arguments to the signal-catching
function.  The system passes the signal number.

>The same question is for setjmp(Env) and longjmp(Env, 0):
>    are there any ways to get rid of the global variable Env?

There's no requirement that `Env' be a global variable.  It's a
structure into which setjmp() saves the process state at the time
setjmp() is called.  A process is allowed to save any number of
non-global jmpbuf structures, and feed the structure of its choice to
longjmp() to jump to the desired state.
-- 

	Chuck Karish		karish at mindcraft.com
	Mindcraft, Inc.		(415) 323-9000		



More information about the Comp.unix.questions mailing list