[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

[LI] Catching SIGSEGV



Hi,
	A program I wrote used a signal handler for SIGSEGV. I originally compiled it without any extra flags. When any instruction in the program seg. faulted, it would get a large no. of Segmentation fault signals (I checked with strace and ltrace), and the program would exit. The same program, if compiled with optimization flags (-O2) would work as expected. I tried compiling with both gcc and egcs under RH5.2 and egcs in RH6.1. The program fragment is given below

jmp_buf env;

void seg_catch()
{
	printf("<Seg. fault>\n");
	longjmp(env, 1);
}
main()
{
	......	/* Setup handlers etc. */
	......
	if (setjmp(env) == 0) {
		....
		<seg. faulting statements>
	} else {
		....
	}
}

--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.