void _threadnote(void *v, char *s) { Proc *p; Note *n; _threaddebug(DBGNOTE, "Got note %s", s); // if(strncmp(s, "sys:", 4) == 0) // noted(NDFLT); // if(_threadexitsallstatus){ // _threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'\n", _threadexitsallstatus); // _exits(_threadexitsallstatus); // } if(strcmp(s, "threadint")==0) noted(NCONT); p = _threadgetproc(); if(p == nil) noted(NDFLT); for(n=notes; n<enotes; n++) if(canlock(&n->inuse)) break; if(n==enotes) sysfatal("libthread: too many delayed notes"); utfecpy(n->s, n->s+ERRMAX, s); n->proc = p; p->pending = 1; if(!p->splhi) delayednotes(p, v); noted(NCONT); }
void notifyf(void *a, char *msg) { if(strcmp(msg, "interrupt") == 0) noted(NCONT); noted(NDFLT); }
void ding(void *, char *msg) { if(strstr(msg, "alarm") != nil) noted(NCONT); noted(NDFLT); }
/* this is registered in _envsetup */ int _notehandler(void *u, char *msg) { int i; void(*f)(int, char*, Ureg*); extern void _doatexits(void); /* in stdio/exit.c */ if(_finishing) _finish(0, 0); for(i = 0; i<NSIGTAB; i++){ if(strncmp(msg, sigtab[i].msg, strlen(sigtab[i].msg)) == 0){ f = _sighdlr[sigtab[i].num]; if(f == SIG_DFL || f == SIG_ERR) break; if(f != SIG_IGN) { _notetramp(sigtab[i].num, f, u); /* notetramp is machine-dependent; doesn't return to here */ } noted(0); /* NCONT */ return 0; } } //_doatexits(); noted(1); /* NDFLT */ return 0; }
void catchint(void *a, char *note) { USED(a); if(strcmp(note, "alarm") == 0) noted(NCONT); noted(NDFLT); }
void ding(void*, char *s) { if(strstr(s, "alarm")) noted(NCONT); else noted(NDFLT); }
void catcher(void*, char *msg) { timedout = 1; if(strcmp(msg, "alarm") == 0) noted(NCONT); noted(NDFLT); }
void notifyf(void *a, char *s) { USED(a); if(strncmp(s, "interrupt", 9) == 0) noted(NCONT); noted(NDFLT); }
static void ding(void *v, char *msg) { if(strstr(msg, "alarm") != nil) { stats.alarms++; noted(NCONT); /* resume with system call error */ } else noted(NDFLT); /* die */ }
void ding(void *u, char *msg) { USED(u); if(strstr(msg, "alarm")) noted(NCONT); noted(NDFLT); }
static void cookedcatchint(void*, char *msg) { if(strstr(msg, "interrupt")) noted(NCONT); else if(strstr(msg, "kill")) noted(NDFLT); else noted(NCONT); }
void catcher(void *a, char *msg) { USED(a); if(strcmp(msg, "interrupt") != 0) noted(NDFLT); count = 1; print("ki\n"); noted(NCONT); }
void catchalarm(void *regs, char *msg) { USED(regs); USED(msg); if(strcmp(msg, "alarm") == 0){ alarmed = 1; noted(NCONT); } else noted(NDFLT); }
void catcher(void *junk, char *s) { USED(junk); if(strstr(s, "interrupt")) { gotint = 1; noted(NCONT); } noted(NDFLT); }
/* * An interrupt occurred; * seek to the end of the current file * and remember that there was a fault. */ void fault(void *a, char *s) { USED(a); if(strncmp(s, "interrupt", 9) == 0){ seek(infile, 0L, 2); mkfault++; noted(NCONT); } noted(NDFLT); }
/* * ignore interrupts */ void notifyf(void *a, char *msg) { USED(a); if(strcmp(msg, "interrupt") == 0){ interrupted = 1; noted(NCONT); } if(strcmp(msg, "hangup") == 0) noted(NCONT); noted(NDFLT); }
void notifyf(void *a, char *s) { USED(a); if(bpipeok && strcmp(s, "sys: write on closed pipe") == 0) noted(NCONT); if(strcmp(s, "interrupt") == 0) noted(NCONT); panicking = 1; rescue(); noted(NDFLT); }
void ignore(void *a, char *c) { USED(a); if(strcmp(c, "alarm") == 0){ fprint(2, "srv: timeout establishing connection to %s\n", dest); exits("timeout"); } if(strstr(c, "write on closed pipe") == 0){ fprint(2, "write on closed pipe\n"); noted(NCONT); } noted(NDFLT); }
void alarmed(void *a, char *s) { if(strcmp(s, "alarm") == 0) notejmp(a, catchalarm, 1); noted(NDFLT); }
void _notetramp(int sig, void (*hdlr)(int, char*, Ureg*), Ureg *u) { Pcstack *p; if(nstack >= MAXSIGSTACK) noted(NDFLT); /* nesting too deep; just do system default */ p = &pcstack[nstack]; p->restorepc = u->ip; p->sig = sig; p->hdlr = hdlr; p->u = u; nstack++; u->ip = (uint64_t) notecont; noted(NSAVE); /* clear note but hold state */ }
void failure(void*, char *note) { if(strcmp(note, "failure") == 0) _exits(nil); noted(NDFLT); }
static void delayednotes(Proc *p, void *v) { int i; Note *n; int (*fn)(void*, char*); if(!p->pending) return; p->pending = 0; for(n=notes; n<enotes; n++){ if(n->proc == p){ for(i=0; i<NFN; i++){ if(onnotepid[i]!=p->pid || (fn = onnote[i])==nil) continue; if((*fn)(v, n->s)) break; } if(i==NFN){ _threaddebug(DBGNOTE, "Unhandled note %s, proc %p\n", n->s, p); if(v != nil) noted(NDFLT); else if(strncmp(n->s, "sys:", 4)==0) abort(); threadexitsall(n->s); } n->proc = nil; unlock(&n->inuse); } } }
void bell(void *v, char *msg) { if(strcmp(msg, "alarm") == 0) drawsleep = drawsleep ? 0 : 1000; noted(NCONT); }
void handler(void *v, char *s) { fprint(2, "%d: %d iterations\n", id, i); if (intr++ < 16) noted(NCONT); fprint(2, "FAIL: too many interrupts\n"); exits("FAIL"); }
void catcher(void *u, char *s) { err = 0; if(strncmp(s, "sys: fp:", 8) == 0){ err = s; notejmp(u, errj, 0); } noted(NDFLT); }
void notifyf(void *a, char *s) { if(strcmp(s, "interrupt") == 0){ if(rescuing || waiting) noted(NCONT); putchr(L'\n'); lastc = '\n'; error1(Q); notejmp(a, savej, 0); } if(strcmp(s, "hangup") == 0){ if(rescuing) noted(NDFLT); rescue(); } fprint(2, "ed: note: %s\n", s); abort(); }
void catcher(void*, char *text) { int n; n = strlen(text); if(n >= sizeof(notebuf)) n = sizeof(notebuf)-1; memmove(notebuf, text, n); notebuf[n] = '\0'; noted(NCONT); }
void notejmp(void *vr, jmp_buf j, int ret) { struct Ureg *r = vr; r->r0 = ret; if(ret == 0) r->r0 = 1; r->pc = j[JMPBUFPC]; r->sp = j[JMPBUFSP]; noted(NCONT); }
static void notecont(Ureg *u, char *s) { Pcstack *p; void(*f)(int, char*, Ureg*); p = &pcstack[nstack-1]; f = p->hdlr; u->ip = p->restorepc; nstack--; (*f)(p->sig, s, u); noted(NRSTR); }
void notifyf(void* v, char *s) { int i; for(i = 0;syssigname[i];i++) if(strncmp(s, syssigname[i], strlen(syssigname[i]))==0){ if(strncmp(s, "sys: ", 5)!=0) interrupted = 1; goto Out; } pfmt(err, "rc: note: %s\n", s); noted(NDFLT); return; Out: if(strcmp(s, "interrupt")!=0 || trap[i]==0){ trap[i]++; ntrap++; } if(ntrap>=32){ /* rc is probably in a trap loop */ pfmt(err, "rc: Too many traps (trap %s), aborting\n", s); abort(); } noted(NCONT); }