shithub: riscv

Download patch

ref: 5dcb407add4013d7234dc248fb97c8a5d146e3d3
parent: 7c62868a9fb501b132cb9d2a24b38a19edf13a90
author: aiju <devnull@localhost>
date: Mon Jun 12 15:28:27 EDT 2017

acid: provide hooks 'procattach' and 'dying'

--- a/sys/src/cmd/acid/acid.h
+++ b/sys/src/cmd/acid/acid.h
@@ -178,6 +178,7 @@
 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);
--- a/sys/src/cmd/acid/main.c
+++ b/sys/src/cmd/acid/main.c
@@ -178,6 +178,8 @@
 
 	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 @@
 	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 @@
 		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
--- a/sys/src/cmd/acid/proc.c
+++ b/sys/src/cmd/acid/proc.c
@@ -189,6 +189,8 @@
 	l->next = s->v->l;
 	s->v->l = l;
 	s->v->set = 1;
+	
+	callhook("procattach");
 }
 
 void