home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.lbl.gov
/
2014.05.ftp.ee.lbl.gov.tar
/
ftp.ee.lbl.gov
/
bmd-1.0beta.tar.Z
/
bmd-1.0beta.tar
/
bmd-1.0beta
/
app
/
omtd
/
sig-handler.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-13
|
1KB
|
63 lines
/*
* Copyright (c) 1990 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Lawrence Berkeley Laboratory,
* Berkeley, CA. The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <signal.h>
#include <setjmp.h>
struct fnlist {
int (*f)();
struct fnlist *next;
};
struct fnlist *fns;
static void
sigint()
{
struct fnlist *p;
putchar('\n');
for (p = fns; p != 0; p = p->next)
if ((*p->f)())
break;
}
sigint_push(fn)
int (*fn)();
{
struct fnlist *p = (struct fnlist *)malloc(sizeof(*p));
p->f = fn;
p->next = fns;
fns = p;
}
sigint_pop(fn)
int (*fn)();
{
struct fnlist *p = fns;
fns = fns->next;
free((char *)p);
}
init_sigint_handler()
{
signal(SIGINT, sigint);
}