shithub: zuke

Download patch

ref: 146f6cafca4541da7573162a93ca24526d809bbd
parent: e11985de50aca2b6a958b336e6ccbf209871325b
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Jun 25 09:49:43 EDT 2020

allow only one instance of picker to run, kill picker on exit

--- a/theme.c
+++ b/theme.c
@@ -47,11 +47,13 @@
 	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 @@
 			break;
 	}
 	Bterm(b);
+	postnote(PNGROUP, pid, "interrupt");
 
 	threadexits(nil);
 }
--- a/zuke.c
+++ b/zuke.c
@@ -867,7 +867,7 @@
 		{ 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 @@
 	redraw(1);
 	oldbuttons = 0;
 	scrolling = 0;
+	themetid = -1;
 
 	for(;;){
 ev:
@@ -967,7 +968,7 @@
 			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 @@
 	}
 
 end:
+	threadint(themetid);
 	threadexitsall(nil);
 }