Unix error handling

lance.norskog lance at motcsd.csd.mot.com
Tue Sep 11 09:27:17 AEST 1990


Setjmp() and longjmp() are the basis of UNIX process-switching, and they've
been in the kernel since Version 6 (1976?) and probably since the original
PDP-11 assembler implementation.  This pair are:
	void setjmp(jump buf)
	void longjmp(jump buf)

The user-library pair have been around for probably as long:
	int  setjmp(jump buf)
	void longmmp(jump buf, return val)

	switch (setjmp(jumpbuf)) {
		case 0: original
		case 1: abort
		default: panic, can't happen
	}

    abort:
	longjmp(jumpbuf, 1);

Setjmp() in the user library returns 0 for the setup call, and the
longjmp-supplied value when it comes back from a longjmp().
The kernel pair lacks this functionality.

Of course, better languages let you save off multiple running stacks
and resume them...



More information about the Comp.unix.internals mailing list