trap
if (signo < NSIG && trap[signo] != NULL) {
out1qstr(trap[signo]);
if (trap[signo])
ckfree(trap[signo]);
trap[signo] = action;
for (tp = trap ; tp <= &trap[NSIG - 1] ; tp++) {
if (tp != &trap[0])
setsignal(tp - trap);
for (tp = trap ; tp <= &trap[NSIG - 1] ; tp++) {
if ((t = trap[signo]) == NULL)
return (trap[SIGCHLD] != NULL && *trap[SIGCHLD] != '\0');
if (signo == SIGINT && trap[SIGINT] == NULL) {
if (trap[signo] != NULL && trap[signo][0] != '\0' &&
if (trap[i]) {
evalstring(stsavestr(trap[i]), 0);
if ((p = trap[0]) != NULL && *p != '\0') {
trap[0] = NULL;
static char *volatile trap[NSIG]; /* trap handler commands */
struct trap *ntrap;
extern struct trap *ftrap;
#define newtrap() ((struct trap *) alloc(sizeof(struct trap)))
void deltrap(struct trap *);
struct trap *t_at(int, int);
struct trap *maketrap(int, int, int);
void dotrap(struct trap *);
struct trap *ftrap = 0;
struct trap *ttmp = t_at(dpx, dpy);
struct trap *ttmp = t_at(u.ux, u.uy);
struct trap *ttmp;
struct trap *trap = NULL;
if (!u.uswallow && (trap = t_at(u.ux + u.dx, u.uy + u.dy)) && trap->tseen)
struct trap *ttmp;
if (trap)
dotrap(trap); /* fall into pit, arrow trap, etc. */
struct trap *trap;
if ((info[i] & ALLOW_TRAPS) && (trap = t_at(nx, ny))) {
if (!trap->tseen && rn2(40))
deltrap(struct trap *trap)
struct trap *ttmp;
if (trap == ftrap)
for (ttmp = ftrap; ttmp->ntrap != trap; ttmp = ttmp->ntrap);
ttmp->ntrap = trap->ntrap;
free(trap);
struct trap *
struct trap *trap = ftrap;
while (trap) {
if (trap->tx == x && trap->ty == y)
return (trap);
trap = trap->ntrap;
savetrapchn(int fd, struct trap *trap)
struct trap *trap2;
while (trap) {
trap2 = trap->ntrap;
bwrite(fd, trap, sizeof(struct trap));
free(trap);
trap = trap2;
bwrite(fd, nul, sizeof(struct trap));
struct trap *trap;
trap = newtrap();
mread(fd, trap, sizeof(struct trap));
while (trap->tx) {
trap->ntrap = ftrap;
ftrap = trap;
trap = newtrap();
mread(fd, trap, sizeof(struct trap));
free(trap);
static void savetrapchn(int, struct trap *);
struct trap *ttmp;
struct trap *ttmp;
struct trap *ttmp = t_at(nx, ny);
struct trap *ttmp;
struct trap *ttmp;
struct trap *trap;
for (trap = ftrap; trap; trap = trap->ntrap)
if (trap->tx == x && trap->ty == y &&
!trap->tseen && !rn2(8)) {
pline("You find a%s.", traps[trap->ttyp]);
if (trap->ttyp == PIERC) {
deltrap(trap);
trap->tseen = 1;
struct trap *trap;
for (trap = ftrap; trap; trap = trap->ntrap)
if (trap->tx == x && trap->ty == y && trap->tseen) {
if ((u.dz < 0) != (!xdnstair && trap->ttyp == TRAPDOOR))
pline("That is a%s.", traps[trap->ttyp]);
struct trap *ttmp;
dotrap(struct trap *trap)
int ttype = trap->ttyp;
if (trap->tseen && !rn2(5) && ttype != PIT)
trap->tseen = 1;
deltrap(trap);
if (trap->once) {
deltrap(trap);
impossible("You hit a trap of type %u", trap->ttyp);
struct trap *trap = t_at(mtmp->mx, mtmp->my);
if (!trap) {
int tt = trap->ttyp;
struct trap *trap;
if ((trap = t_at(u.ux, u.uy)) != NULL)
switch (trap->ttyp) {
dotrap(trap);
struct trap *
struct trap *ttmp;
extern trap traps[];
r_write(fp, (char *) traps, (MAX_TRAPS * sizeof(trap)));
r_read(fp, (char *) traps, (MAX_TRAPS * sizeof(trap)));
trap traps[MAX_TRAPS];
signal(SIGINT, trap);
signal(SIGHUP, trap);
signal(SIGTERM, trap);
signal(sig, trap);
extern void trap(struct trapframe *frame);
KTR_INFO(KTR_KERNENTRY, kernentry, trap, 0,
KTR_INFO(KTR_KERNENTRY, kernentry, trap, 0,
void trap(struct smallframe *);