Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: Need help with exception handling Message-ID: <8809041014.AA26988@cory.Berkeley.EDU> Date: 4 Sep 88 10:14:32 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 34 This is an easy one! The problem is that C.LIB is NOT REENTRANT. While the Amiga may be a multitasking machine, this does not mean that linked-in libraries for a given task are reentrant... the run-time libraries certainly are (in most cases), but most of the routines in the link libraries are not. Specifically, STDIO is not reentrant. Of the run-time libraries, the DOS.LIBRARY is not reentrant for a SPECIFIC PROCESS... i.e. many different processes can call it simultaniously, but a given process cannot be in the middle of a DOS command, interrupt itself, and send another DOS command in the interrupt handler. So, your problem is two fold: (1) STDIO is not reentrant and you are interrupting a printf() with the printf() in the exception handler, and (2) DOS is not reentrant on a per-process basis and STDIO calls DOS. -Matt : while (!aborted) { : printf("%d\n",++i); <----------- Adding this brings the guru : } :hdlr() { :/* Note that even AmigaDOS stuff can be done from here */ : printf("Exception %lx Control-",cursigs); : if (cursigs & SIGBREAKF_CTRL_C) {printf("C\n"); aborted=1;} : if (cursigs & SIGBREAKF_CTRL_D) printf("D\n"); : if (cursigs & SIGBREAKF_CTRL_E) printf("E\n"); : if (cursigs & SIGBREAKF_CTRL_F) printf("F\n"); :}