shithub: pplay

Download patch

ref: d8a2915af0e2959ae0c459910048a85c18248372
parent: 703a482160db136fe3ff6c6ba6586230d201a40a
author: qwx <[email protected]>
date: Mon Oct 30 00:41:11 EDT 2023

prevent unfinished external commands from terminating early on exit

basically just want RFNOWAIT|RFREND, but can't do that with libthread
apparently

--- a/cmd.c
+++ b/cmd.c
@@ -126,6 +126,7 @@
 {
 	int fd;
 
+	threadsetgrp(1);
 	fd = (intptr)efd;
 	writebuf(fd);
 	close(fd);
@@ -239,6 +240,15 @@
 	return 0;
 }
 
+void
+quit(void)
+{
+	threadsetgrp(1);
+	threadkillgrp(0);
+	threadintgrp(0);
+	threadexits(nil);
+}
+
 int
 cmd(char *s)
 {
@@ -270,7 +280,7 @@
 	case 'j': x = jumpto(s); break;
 	//case 'm': x = mark(s); break;
 	case 'p': x = paste(s); break;
-	case 'q': threadexitsall(nil);
+	case 'q': quit();
 	case 'r': x = readfrom(s); break;
 	case 's': x = replicate(s); break;
 	case 'U': x = unpop(s); break;
--- a/fns.h
+++ b/fns.h
@@ -8,6 +8,7 @@
 void	ccut(Dot*);
 void	ccrop(Dot*);
 Chunk*	loadfile(int, Dot*);
+void	quit(void);
 int	cmd(char*);
 int	initcmd(int);
 void	refresh(int);
--- a/pplay.c
+++ b/pplay.c
@@ -169,7 +169,7 @@
 		case 2:
 			switch(r){
 			case Kdel:
-			case 'q': threadexitsall(nil);
+			case 'q': quit();
 			case 'D': debug ^= 1; debugdraw ^= 1; refresh(Drawrender); break;
 			case 'S': stereo ^= 1; redraw(1); break;
 			case ' ': toggleplay(); break;