DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T s

⟦33ca27907⟧ TextFile

    Length: 1569 (0x621)
    Types: TextFile
    Names: »signals.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/signals.c« 

TextFile

#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
#include "sysdep.h"
#include "macros.h"

extern	jmp_buf interrupt;
static	int critlevel, handling_yet;
#if CKPTIME > 0
extern	int wakeup();
#endif

#ifdef sun
#define	sighandler	(void (*)())
#else
#define	sighandler	(int (*)())
#endif

int_hand()

{
	(void) fflush(stdout);
	longjmp(interrupt, SIGINT);
}

hup_hand()	{ panic("Hangup received"); }
term_hand()	{ panic("Terminate signal received"); }
quit_hand()	{ panic("Quit signal received"); }

setsignals()

{
	extern int root;

	(void) signal(SIGQUIT, sighandler quit_hand);
	(void) signal(SIGINT, sighandler int_hand);
	if (root) {
	    (void) signal(SIGHUP, sighandler hup_hand);
	    (void) signal(SIGTERM, sighandler term_hand);
#if CKPTIME > 0
	    (void) signal(SIGALRM, sighandler wakeup);
#endif
	}
	(void) sigsetmask(0);
	handling_yet = 1;
}

tstp()

{
	(void) kill(getpid(), SIGTSTP);
	return;
}

/*
 * Keep user from interrupting the program during a critical section
 * of code.  Used when updating interdependent data structures to insure
 * consistency. Also used by the memory management routines to make sure
 * allocations and free's are atomic.
 */
critical()

{
	if (!handling_yet) return;
	if (!critlevel++) {
		(void) signal(SIGINT, sighandler SIG_IGN);
		(void) sigsetmask(mask(SIGHUP)|mask(SIGTERM)|
					mask(SIGQUIT)|mask(SIGALRM));
	}
	return;
}

/*
 * Critical's other half
 */
non_critical()

{
	if (!handling_yet) return;
	if (!--critlevel) {
		(void) signal(SIGINT, sighandler int_hand);
		(void) sigsetmask(0);
	}
	return;
}