page, mothra: corral rogue note groups

This commit is contained in:
cinap_lenrek 2011-12-21 07:45:30 +01:00
parent 4fe344847c
commit 1d83d2a74e
2 changed files with 23 additions and 6 deletions

View file

@ -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);

View file

@ -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)