do not call exits in threaded programs

This commit is contained in:
rsc 2005-01-17 21:29:00 +00:00
parent e33c70bc72
commit 38c10d1abc
8 changed files with 25 additions and 17 deletions

View file

@ -23,6 +23,14 @@ void _threadsleep(Rendez*);
_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
*/

View file

@ -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/elem\n");
exits("usage");
threadexitsall("usage");
}
void xread(int, char**);
@ -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
@ -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
@ -196,7 +196,7 @@ xwrite(int argc, char **argv)
}
if(n < 0)
sysfatal("read error: %r");
exits(0);
threadexitsall(0);
}
void
@ -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
@ -245,5 +245,5 @@ xstat(int argc, char **argv)
fmtinstall('D', dirfmt);
fmtinstall('M', dirmodefmt);
print("%D\n", d);
exits(0);
threadexitsall(0);
}

View file

@ -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];

View file

@ -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);
}

View file

@ -114,7 +114,7 @@ threadmain(int argc, char *argv[])
default:
Usage:
fprint(2, "usage: acme -a -c ncol -f fontname -F fixedwidthfontname -l loadfile -W winsize\n");
exits("usage");
threadexitsall("usage");
}ARGEND
fontnames[0] = estrdup(fontnames[0]);
@ -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;
@ -192,19 +192,19 @@ threadmain(int argc, char *argv[])
chansetname(cwarn, "cwarn");
if(cwait==nil || ccommand==nil || ckill==nil || cxfidalloc==nil || cxfidfree==nil || cerr==nil || cexit==nil || cwarn==nil){
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();

View file

@ -33,7 +33,7 @@ void
usage(void)
{
fprint(2, "usage: %s [-df] [-s service] [-n remote-ns] [-p remote-prog] remote-system\n", argv0);
exits("usage");
threadexitsall("usage");
}
void

View file

@ -105,7 +105,7 @@ static void
usage(void)
{
fprint(2, "usage: %s [-amqsv] [-h host] [-d vacfile] [-b blocksize] [-i name] [-e exclude] [-f vacfile] file ... \n", argv0);
exits("usage");
threadexitsall("usage");
}
void

View file

@ -206,7 +206,7 @@ void
usage(void)
{
fprint(2, "usage: %s [-sd] [-h host] [-c ncache] [-m mountpoint] vacfile\n", argv0);
exits("usage");
threadexitsall("usage");
}
char*