ref: ea7644951223db92fb058a206d85423b7652998e
parent: 0ab7b7204c67da088e58dbc00a49813c432ce353
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Aug 13 17:46:13 EDT 2013
libdraw: fix leftover processes or programs failing to restore window labels when receiving interrupt note fix the default note handler for event programs. only handle non system notes or notes in the slave processes. for interrupt in the main process, just call exits() which will do the cleanup and restore window label properly. this makes completely overriding the note handler in gping and stats uneccesary.
--- a/sys/src/cmd/ip/gping.c
+++ b/sys/src/cmd/ip/gping.c
@@ -630,17 +630,7 @@
*vmax = 100;
}
-jmp_buf catchalarm;
-
void
-alarmed(void *a, char *s)
-{- if(strcmp(s, "alarm") == 0)
- notejmp(a, catchalarm, 1);
- noted(NDFLT);
-}
-
-void
usage(void)
{fprint(2, "usage: %s machine [machine...]\n", argv0);
@@ -1030,7 +1020,6 @@
}
colinit();
einit(Emouse);
- notify(nil);
startproc(mouseproc, 0);
display->locking = 1; /* tell library we're using the display lock */
--- a/sys/src/cmd/stats.c
+++ b/sys/src/cmd/stats.c
@@ -710,12 +710,12 @@
jmp_buf catchalarm;
-void
+int
alarmed(void *a, char *s)
{if(strcmp(s, "alarm") == 0)
notejmp(a, catchalarm, 1);
- noted(NDFLT);
+ return 0;
}
int
@@ -781,7 +781,7 @@
eresized(0);
}
if(m->remote){- notify(alarmed);
+ atnotify(alarmed, 1);
alarm(5000);
}
if(needswap(init) && loadbuf(m, &m->swapfd) && readswap(m, a))
@@ -809,7 +809,7 @@
m->temp[n] = a[0];
if(m->remote){alarm(0);
- notify(nil);
+ atnotify(alarmed, 0);
}
}
@@ -1410,7 +1410,6 @@
}
colinit();
einit(Emouse);
- notify(nil);
startproc(mouseproc, Mouseproc);
pids[Mainproc] = getpid();
display->locking = 1; /* tell library we're using the display lock */
--- a/sys/src/libdraw/event.c
+++ b/sys/src/libdraw/event.c
@@ -346,39 +346,33 @@
}
static int
-enote(void *v, char *s)
+enote(void*, char *s)
{- char t[1];
int i, pid;
- USED(v, s);
- pid = getpid();
- if(pid != parentpid){- for(i=0; i<nslave; i++){- if(pid == eslave[i].pid){- t[0] = MAXSLAVE;
- write(epipe[1], t, 1);
- break;
- }
- }
+ if(strncmp(s, "sys:", 4) == 0 || strcmp(s, "alarm") == 0)
return 0;
- }
- close(epipe[0]);
- epipe[0] = -1;
- close(epipe[1]);
- epipe[1] = -1;
- for(i=0; i<nslave; i++){+ pid = getpid();
+ for(i=0; i<nslave; i++)
if(pid == eslave[i].pid)
- continue; /* don't kill myself */
- postnote(PNPROC, eslave[i].pid, "die");
- }
- return 0;
+ return 1;
+ if(pid != parentpid)
+ return 0;
+ exits("killed");+ return 1;
}
static void
ekill(void)
{- enote(0, 0);
+ int i, pid;
+
+ pid = getpid();
+ for(i=0; i<nslave; i++){+ if(pid == eslave[i].pid)
+ continue; /* don't kill myself */
+ postnote(PNPROC, eslave[i].pid, "die");
+ }
}
Mouse
--
⑨