acid: provide hooks 'procattach' and 'dying'

This commit is contained in:
aiju 2017-06-12 19:28:27 +00:00
parent 7c62868a9f
commit 5dcb407add
3 changed files with 23 additions and 9 deletions

View file

@ -178,6 +178,7 @@ void append(Node*, Node*, Node*);
int bool(Node*);
void build(Node*);
void call(char*, Node*, Node*, Node*, Node*);
int callhook(char*);
void catcher(void*, char*);
void checkqid(int, int);
void cmd(void);

View file

@ -178,6 +178,8 @@ die(void)
Bprint(bout, "\n");
if(setjmp(err) == 0)
callhook("dying");
s = look("proclist");
if(s && s->v->type == TLIST) {
for(f = s->v->l; f; f = f->next)
@ -196,11 +198,26 @@ loadmoduleobjtype(void)
free(buf);
}
void
userinit(void)
int
callhook(char *name)
{
Lsym *l;
Node *n;
l = look(name);
if(l && l->proc) {
n = an(ONAME, ZN, ZN);
n->sym = l;
n = an(OCALL, n, ZN);
execute(n);
return 0;
}
return -1;
}
void
userinit(void)
{
char *buf, *p;
p = getenv("home");
@ -216,13 +233,7 @@ userinit(void)
unwind();
return;
}
l = look("acidinit");
if(l && l->proc) {
n = an(ONAME, ZN, ZN);
n->sym = l;
n = an(OCALL, n, ZN);
execute(n);
}
callhook("acidinit");
}
void

View file

@ -189,6 +189,8 @@ install(int pid)
l->next = s->v->l;
s->v->l = l;
s->v->set = 1;
callhook("procattach");
}
void