summaryrefslogtreecommitdiff
path: root/sys/src/cmd
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-12-21 07:45:30 +0100
committercinap_lenrek <cinap_lenrek@centraldogma>2011-12-21 07:45:30 +0100
commit1d83d2a74e54382ef9182ad7b136a676c6a8be1c (patch)
tree5ed2a3f635640fd1f6fc117b4a5acad12da224c6 /sys/src/cmd
parent4fe344847cebf9fd9071d83c6bf7ed7a6c1da35e (diff)
page, mothra: corral rogue note groups
Diffstat (limited to 'sys/src/cmd')
-rw-r--r--sys/src/cmd/mothra/mothra.c16
-rw-r--r--sys/src/cmd/page.c13
2 files changed, 23 insertions, 6 deletions
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c
index 8ab367cfc..a95333682 100644
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -204,13 +204,17 @@ void mkpanels(void){
alttext=pltextview(alt, PACKE|EXPAND, Pt(0, 0), 0, dolink);
plscroll(alttext, 0, bar);
}
+int cohort = -1;
void killcohort(void){
int i;
for(i=0;i!=3;i++){ /* It's a long way to the kitchen */
- postnote(PNGROUP, getpid(), "kill\n");
+ postnote(PNGROUP, cohort, "kill\n");
sleep(1);
}
}
+void catch(void*, char*){
+ noted(NCONT);
+}
void dienow(void*, char*){
noted(NDFLT);
}
@@ -272,8 +276,15 @@ void main(int argc, char *argv[]){
* so that we can stop all subprocesses with a note,
* and to isolate rendezvous from other processes
*/
- rfork(RFNOTEG|RFNAMEG|RFREND);
+ if(cohort = rfork(RFPROC|RFNOTEG|RFNAMEG|RFREND)){
+ atexit(killcohort);
+ notify(catch);
+ waitpid();
+ exits(0);
+ }
+ cohort = getpid();
atexit(killcohort);
+
switch(argc){
default:
Usage:
@@ -677,7 +688,6 @@ void docmd(Panel *p, char *s){
save(urlopen(selection, GET, 0), s);
break;
case 'q':
- draw(screen, screen->r, display->white, 0, ZP);
exits(0);
}
plinitentry(cmd, EXPAND, 0, "", docmd);
diff --git a/sys/src/cmd/page.c b/sys/src/cmd/page.c
index e5445e671..dffedc0c4 100644
--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -1160,11 +1160,12 @@ eresized(int new)
unlockdisplay(display);
}
+int cohort = -1;
void killcohort(void)
{
int i;
for(i=0;i!=3;i++){ /* It's a long way to the kitchen */
- postnote(PNGROUP, getpid(), "kill");
+ postnote(PNGROUP, cohort, "kill");
sleep(1);
}
}
@@ -1219,9 +1220,15 @@ main(int argc, char *argv[])
* so that we can stop all subprocesses with a note,
* and to isolate rendezvous from other processes
*/
- rfork(RFNOTEG|RFNAMEG|RFREND);
- atexit(killcohort);
atnotify(catchnote, 1);
+ if(cohort = rfork(RFPROC|RFNOTEG|RFNAMEG|RFREND)){
+ atexit(killcohort);
+ waitpid();
+ exits(0);
+ }
+ cohort = getpid();
+ atexit(killcohort);
+
if(newwin > 0){
s = smprint("-pid %d", getpid());
if(newwindow(s) < 0)