[comp.sys.amiga] Signals... a great tool

peter@sugar.UUCP (Peter da Silva) (08/03/87)

I think having four seperate break levels is a little redundent... does
anyone actually use them? But here's what you should do.

	flags = Wait(whatever_other_signals |
		SIGBREAKF_CTRL_C |
		SIGBREAKF_CTRL_D |
		SIGBREAKF_CTRL_E |
		SIGBREAKF_CTRL_F);

	if(flags & SIGBREAKF_CTRL_C) {
		printf("^C\n");
		close files in an orderly fashion.
		exit(RETURN_ERROR);
	}
	if(flags & (SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F) ) {
		do absolute minimal cleanup
		exit(RETURN_FAIL);
	}

	process other signals and messages.

Speaking of signals... BEWARE! Just because Wait() says a message has come,
don't assume it's actually come. Wait sometimes returns a signal bit set
even with no message available on the port... particularly if you've just
opened a device. Moral: always check the return from GetMsg().
-- 
-- Peter da Silva `-_-' ...!seismo!soma!uhnix1!sugar!peter (I said, NO PHOTOS!)