summaryrefslogtreecommitdiff
path: root/sys/src/9/sgi
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2022-08-17 15:21:22 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2022-08-17 15:21:22 +0000
commitc8e25d2a18c0395431abc5818a1d2f0561b0181f (patch)
treea087f5850d7374b5cfd624244237e97b7937d5fe /sys/src/9/sgi
parent7828ffb8a486e188b61394436a434e8cae4fd487 (diff)
kernel: simplify notify() adding common popnote() function
Handlin notes is common for all architectures except how the note has to be pushed on the user stack. This change adds a popnote() function that returns only the note string or nil if the process should not be notified (no notes or user notes hold off). Popnote() also handles common errors like notify during note handling or missing note handler and will suicide the process in that case.
Diffstat (limited to 'sys/src/9/sgi')
-rw-r--r--sys/src/9/sgi/trap.c36
1 files changed, 5 insertions, 31 deletions
diff --git a/sys/src/9/sgi/trap.c b/sys/src/9/sgi/trap.c
index c97ee7d08..da1542752 100644
--- a/sys/src/9/sgi/trap.c
+++ b/sys/src/9/sgi/trap.c
@@ -470,9 +470,9 @@ dumpregs(Ureg *ur)
int
notify(Ureg *ur)
{
- int l, s;
+ int s;
ulong sp;
- Note *n;
+ char *msg;
if(up->procctl)
procctl();
@@ -487,34 +487,13 @@ notify(Ureg *ur)
s = spllo();
qlock(&up->debug);
- up->notepending = 0;
- n = &up->note[0];
- if(strncmp(n->msg, "sys:", 4) == 0) {
- l = strlen(n->msg);
- if(l > ERRMAX-15) /* " pc=0x12345678\0" */
- l = ERRMAX-15;
-
- seprint(n->msg+l, &n->msg[sizeof n->msg], " pc=%#lux", ur->pc);
- }
-
- if(n->flag != NUser && (up->notified || up->notify==0)) {
- if(n->flag == NDebug)
- pprint("suicide: %s\n", n->msg);
-
- qunlock(&up->debug);
- pexit(n->msg, n->flag!=NDebug);
- }
-
- if(up->notified) {
+ msg = popnote(ur);
+ if(msg == nil){
qunlock(&up->debug);
splx(s);
return 0;
}
- if(!up->notify) {
- qunlock(&up->debug);
- pexit(n->msg, n->flag!=NDebug);
- }
sp = ur->usp & ~(BY2V-1);
sp -= sizeof(Ureg);
@@ -530,7 +509,7 @@ notify(Ureg *ur)
up->ureg = (void*)sp;
sp -= BY2WD+ERRMAX;
- memmove((char*)sp, up->note[0].msg, ERRMAX); /* push err string */
+ memmove((char*)sp, msg, ERRMAX); /* push err string */
sp -= 3*BY2WD;
*(ulong*)(sp+2*BY2WD) = sp+3*BY2WD; /* arg 2 is string */
@@ -544,11 +523,6 @@ notify(Ureg *ur)
*/
ur->pc = (ulong)up->notify;
- up->notified = 1;
- up->nnote--;
- memmove(&up->lastnote, &up->note[0], sizeof(Note));
- memmove(&up->note[0], &up->note[1], up->nnote*sizeof(Note));
-
qunlock(&up->debug);
splx(s);
return 1;