~ft/zuke

146f6cafca4541da7573162a93ca24526d809bbd — Sigrid Haflínudóttir 6 months ago e11985d
allow only one instance of picker to run, kill picker on exit
2 files changed, 8 insertions(+), 3 deletions(-)

M theme.c
M zuke.c
M theme.c => theme.c +4 -1
@@ 47,11 47,13 @@ themeproc(void *audio)
	Biobuf *b;
	char *s, *v[3];
	int p[3], n, i;
	static int pid;

	threadsetname("themeproc");
	pipe(p);
	p[2] = *(int*)audio;
	procrfork(runpicker, p, 4096, RFFDG|RFNAMEG);
	postnote(PNGROUP, pid, "interrupt");
	pid = threadpid(procrfork(runpicker, p, 4096, RFFDG|RFNAMEG|RFNOTEG));
	close(p[0]);
	b = Bfdopen(p[1], OREAD);



@@ 81,6 83,7 @@ themeproc(void *audio)
			break;
	}
	Bterm(b);
	postnote(PNGROUP, pid, "interrupt");

	threadexits(nil);
}

M zuke.c => zuke.c +4 -2
@@ 867,7 867,7 @@ threadmain(int argc, char **argv)
		{ nil, &key, CHANRCV },
		{ nil, nil, CHANEND },
	};
	int fd, n, scrolling, oldpcur, oldbuttons, pnew, shuffled;
	int fd, n, scrolling, oldpcur, oldbuttons, pnew, shuffled, themetid;

	shuffled = 0;
	ARGBEGIN{


@@ 927,6 927,7 @@ threadmain(int argc, char **argv)
	redraw(1);
	oldbuttons = 0;
	scrolling = 0;
	themetid = -1;

	for(;;){
ev:


@@ 967,7 968,7 @@ ev:
			if(m.buttons == 4){
				n = menuhit(3, mctl, &menu3, nil);
				if(n == 0)
					procrfork(themeproc, &audio, 4096, RFNOTEG);
					themetid = proccreate(themeproc, &audio, 4096);
				else if(n == 1)
					goto end;
				goto ev;


@@ 1112,5 1113,6 @@ ev:
	}

end:
	threadint(themetid);
	threadexitsall(nil);
}