tdo not call exits in threaded programs - plan9port - [fork] Plan 9 from user s… | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 38c10d1abcab399ce3735ccf54672a5b6787165e | |
parent e33c70bc72fa4af9d2261ed6d864bd13b8af9be5 | |
Author: rsc <devnull@localhost> | |
Date: Mon, 17 Jan 2005 21:29:00 +0000 | |
do not call exits in threaded programs | |
Diffstat: | |
M include/thread.h | 8 ++++++++ | |
M src/cmd/9p.c | 12 ++++++------ | |
M src/cmd/9pserve.c | 2 +- | |
M src/cmd/9term/9term.c | 2 +- | |
M src/cmd/acme/acme.c | 12 ++++++------ | |
M src/cmd/import.c | 2 +- | |
M src/cmd/vac/vac.c | 2 +- | |
M src/cmd/vac/vacfs.c | 2 +- | |
8 files changed, 25 insertions(+), 17 deletions(-) | |
--- | |
diff --git a/include/thread.h b/include/thread.h | |
t@@ -24,6 +24,14 @@ _Thread *_threadwakeup(Rendez*); | |
#define yield threadyield | |
/* | |
+ * I am tired of making this mistake. | |
+ */ | |
+#define exits do_not_call_exits_in_threaded_programs | |
+#define _exits do_not_call__exits_in_threaded_programs | |
+ | |
+ | |
+ | |
+/* | |
* signals | |
*/ | |
void threadnotify(int(*f)(void*,char*), int); | |
diff --git a/src/cmd/9p.c b/src/cmd/9p.c | |
t@@ -19,7 +19,7 @@ usage(void) | |
fprint(2, " stat name\n"); | |
// fprint(2, " ls name\n"); | |
fprint(2, "without -a, name elem/path means /path on server unix!$ns/e… | |
- exits("usage"); | |
+ threadexitsall("usage"); | |
} | |
void xread(int, char**); | |
t@@ -142,7 +142,7 @@ xread(int argc, char **argv) | |
write(1, buf, n); | |
if(n < 0) | |
sysfatal("read error: %r"); | |
- exits(0); | |
+ threadexitsall(0); | |
} | |
void | |
t@@ -165,7 +165,7 @@ xreadfd(int argc, char **argv) | |
write(1, buf, n); | |
if(n < 0) | |
sysfatal("read error: %r"); | |
- exits(0); | |
+ threadexitsall(0); | |
} | |
void | |
t@@ -196,7 +196,7 @@ xwrite(int argc, char **argv) | |
} | |
if(n < 0) | |
sysfatal("read error: %r"); | |
- exits(0); | |
+ threadexitsall(0); | |
} | |
void | |
t@@ -220,7 +220,7 @@ xwritefd(int argc, char **argv) | |
sysfatal("write error: %r"); | |
if(n < 0) | |
sysfatal("read error: %r"); | |
- exits(0); | |
+ threadexitsall(0); | |
} | |
void | |
t@@ -245,5 +245,5 @@ xstat(int argc, char **argv) | |
fmtinstall('D', dirfmt); | |
fmtinstall('M', dirmodefmt); | |
print("%D\n", d); | |
- exits(0); | |
+ threadexitsall(0); | |
} | |
diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c | |
t@@ -119,7 +119,7 @@ usage(void) | |
{ | |
fprint(2, "usage: 9pserve [-lv] address\n"); | |
fprint(2, "\treads/writes 9P messages on stdin/stdout\n"); | |
- exits("usage"); | |
+ threadexitsall("usage"); | |
} | |
uchar vbuf[128]; | |
diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c | |
t@@ -1064,7 +1064,7 @@ consread(void) | |
*/ | |
s = setecho(sfd, 0); | |
if(write(rcfd, buf, n) < 0) | |
- exits(0); | |
+ threadexitsall(0); | |
if(s) | |
setecho(sfd, s); | |
} | |
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c | |
t@@ -114,7 +114,7 @@ threadmain(int argc, char *argv[]) | |
default: | |
Usage: | |
fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfon… | |
- exits("usage"); | |
+ threadexitsall("usage"); | |
}ARGEND | |
fontnames[0] = estrdup(fontnames[0]); | |
t@@ -147,12 +147,12 @@ threadmain(int argc, char *argv[]) | |
/* | |
if(geninitdraw(nil, derror, fontnames[0], "acme", nil, Refnone) < 0){ | |
fprint(2, "acme: can't open display: %r\n"); | |
- exits("geninitdraw"); | |
+ threadexitsall("geninitdraw"); | |
} | |
*/ | |
if(initdraw(derror, fontnames[0], "acme") < 0){ | |
fprint(2, "acme: can't open display: %r\n"); | |
- exits("initdraw"); | |
+ threadexitsall("initdraw"); | |
} | |
d = display; | |
t@@ -192,19 +192,19 @@ threadmain(int argc, char *argv[]) | |
chansetname(cwarn, "cwarn"); | |
if(cwait==nil || ccommand==nil || ckill==nil || cxfidalloc==nil || cxf… | |
fprint(2, "acme: can't create initial channels: %r\n"); | |
- exits("channels"); | |
+ threadexitsall("channels"); | |
} | |
mousectl = initmouse(nil, screen); | |
if(mousectl == nil){ | |
fprint(2, "acme: can't initialize mouse: %r\n"); | |
- exits("mouse"); | |
+ threadexitsall("mouse"); | |
} | |
mouse = &mousectl->m; | |
keyboardctl = initkeyboard(nil); | |
if(keyboardctl == nil){ | |
fprint(2, "acme: can't initialize keyboard: %r\n"); | |
- exits("keyboard"); | |
+ threadexitsall("keyboard"); | |
} | |
mainpid = getpid(); | |
startplumbing(); | |
diff --git a/src/cmd/import.c b/src/cmd/import.c | |
t@@ -33,7 +33,7 @@ void | |
usage(void) | |
{ | |
fprint(2, "usage: %s [-df] [-s service] [-n remote-ns] [-p remote-prog… | |
- exits("usage"); | |
+ threadexitsall("usage"); | |
} | |
void | |
diff --git a/src/cmd/vac/vac.c b/src/cmd/vac/vac.c | |
t@@ -105,7 +105,7 @@ static void | |
usage(void) | |
{ | |
fprint(2, "usage: %s [-amqsv] [-h host] [-d vacfile] [-b blocksize] [-… | |
- exits("usage"); | |
+ threadexitsall("usage"); | |
} | |
void | |
diff --git a/src/cmd/vac/vacfs.c b/src/cmd/vac/vacfs.c | |
t@@ -206,7 +206,7 @@ void | |
usage(void) | |
{ | |
fprint(2, "usage: %s [-sd] [-h host] [-c ncache] [-m mountpoint] vacfi… | |
- exits("usage"); | |
+ threadexitsall("usage"); | |
} | |
char* |