diff options
author | spew <devnull@localhost> | 2017-03-25 13:51:33 -0500 |
---|---|---|
committer | spew <devnull@localhost> | 2017-03-25 13:51:33 -0500 |
commit | b2b80a3da5d03ddb2f9cb15c4cf769a432e347ee (patch) | |
tree | 5144ec95d7a0fc00082733c33530fbe2d2339447 /sys/src/games | |
parent | 85b8d253d496c115766a37f51ea72cbec78090a8 (diff) |
games/galaxy: fix exit race condition by pausing the galaxy before threadexitsall
Diffstat (limited to 'sys/src/games')
-rw-r--r-- | sys/src/games/galaxy/galaxy.c | 19 | ||||
-rw-r--r-- | sys/src/games/galaxy/galaxy.h | 2 |
2 files changed, 15 insertions, 6 deletions
diff --git a/sys/src/games/galaxy/galaxy.c b/sys/src/games/galaxy/galaxy.c index 4be0334c6..faa4cf8ef 100644 --- a/sys/src/games/galaxy/galaxy.c +++ b/sys/src/games/galaxy/galaxy.c @@ -442,7 +442,7 @@ domenu(void) G *= z; break; case EXIT: - threadexitsall(nil); + quit(nil); break; } drawglxy(); @@ -496,14 +496,14 @@ kbdthread(void*) 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 @@ tovector(Point p) } 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"); } diff --git a/sys/src/games/galaxy/galaxy.h b/sys/src/games/galaxy/galaxy.h index a09ab204c..9d51aa158 100644 --- a/sys/src/games/galaxy/galaxy.h +++ b/sys/src/games/galaxy/galaxy.h @@ -49,6 +49,8 @@ enum { BODY, }; +void quit(char*); + Image *randcol(void); Point topoint(Vector); Vector tovector(Point); |