ref: af1cdfd017a285facb9d9e21879d6b1150d646de
parent: 2c91e47bbfa50b615b591fc70d00e6bcf9943390
author: spew <devnull@localhost>
date: Sat Mar 25 09:51:33 EDT 2017
games/galaxy: fix exit race condition by pausing the galaxy before threadexitsall
--- a/sys/src/games/galaxy/galaxy.c
+++ b/sys/src/games/galaxy/galaxy.c
@@ -442,7 +442,7 @@
G *= z;
break;
case EXIT:
- threadexitsall(nil);
+ quit(nil);
break;
}
drawglxy();
@@ -496,14 +496,14 @@
for(;;) {recv(realkc->c, &r);
- if(r == Kdel) {- threadexitsall(nil);
- }
+ if(r == Kdel)
+ quit(nil);
+
if(kc.c != nil)
send(kc.c, &r);
else switch(r) {case 'q':
- threadexitsall(nil);
+ quit(nil);
break;
case 's':
stats ^= 1;
@@ -539,9 +539,16 @@
}
void
+quit(char *e)
+{+ pause(0, 0);
+ threadexitsall(e);
+}
+
+void
usage(void)
{- fprint(2, "Usage: %s [-t throttle] [-G gravity] [-ε smooth] [-i] [file]\n", argv0);
+ fprint(2, "Usage: %s [-t throttle] [-G gravity] [-ε smooth] [-p extraproc] [-i] [file]\n", argv0);
threadexitsall("usage");}
--- a/sys/src/games/galaxy/galaxy.h
+++ b/sys/src/games/galaxy/galaxy.h
@@ -49,6 +49,8 @@
BODY,
};
+void quit(char*);
+
Image *randcol(void);
Point topoint(Vector);
Vector tovector(Point);
--
⑨