aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-28 01:37:18 +0000
committerrsc <devnull@localhost>2004-12-28 01:37:18 +0000
commit7ffc5208a82cd7339c125956a9702ac08c0ff2f4 (patch)
treec44cb9750f5f8c77941c9d9090e1058c6f47ebf4
parent96d6b19dcd4f359c3fa8eefcb8615082c840e184 (diff)
downloadplan9port-7ffc5208a82cd7339c125956a9702ac08c0ff2f4.tar.gz
plan9port-7ffc5208a82cd7339c125956a9702ac08c0ff2f4.tar.bz2
plan9port-7ffc5208a82cd7339c125956a9702ac08c0ff2f4.zip
use threaddaemonize
-rw-r--r--src/cmd/9pserve.c22
-rw-r--r--src/cmd/plumb/plumber.c13
2 files changed, 9 insertions, 26 deletions
diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c
index b3917a82..6ea58e77 100644
--- a/src/cmd/9pserve.c
+++ b/src/cmd/9pserve.c
@@ -149,19 +149,8 @@ threadmain(int argc, char **argv)
if((afd = announce(addr, adir)) < 0)
sysfatal("announce %s: %r", addr);
- if(verbose) fprint(2, "9pserve forking\n");
- switch(fork()){
- case -1:
- sysfatal("fork: %r");
- case 0:
- if(verbose) fprint(2, "running mainproc\n");
- mainproc(nil);
- if(verbose) fprint(2, "mainproc finished\n");
- _exits(0);
- default:
- if(verbose) fprint(2, "9pserve exiting\n");
- _exits(0);
- }
+ threaddaemonize();
+ mainproc(nil);
}
void
@@ -220,6 +209,7 @@ listenthread(void *arg)
io = ioproc();
USED(arg);
+ threadsetname("listen %s", adir);
for(;;){
c = emalloc(sizeof(Conn));
c->fd = iolisten(io, adir, c->dir);
@@ -284,6 +274,7 @@ connthread(void *arg)
Ioproc *io;
c = arg;
+ threadsetname("conn %s", c->dir);
io = ioproc();
fd = ioaccept(io, c->fd, c->dir);
if(fd < 0){
@@ -491,7 +482,7 @@ openfdthread(void *v)
c = v;
fid = c->fdfid;
io = ioproc();
-
+ threadsetname("openfd %s", c->fdfid);
tot = 0;
m = nil;
if(c->fdmode == OREAD){
@@ -655,6 +646,7 @@ connoutthread(void *arg)
c = arg;
outq = c->outq;
io = ioproc();
+ threadsetname("connout %s", c->dir);
while((m = recvq(outq)) != nil){
err = m->tx.type+1 != m->rx.type;
if(!err && m->isopenfd)
@@ -714,6 +706,7 @@ outputthread(void *arg)
USED(arg);
io = ioproc();
+ threadsetname("output");
while((m = recvq(outq)) != nil){
if(verbose > 1) fprint(2, "* <- %F\n", &m->tx);
rewritehdr(&m->tx, m->tpkt);
@@ -734,6 +727,7 @@ inputthread(void *arg)
Msg *m;
Ioproc *io;
+ threadsetname("input");
if(verbose) fprint(2, "input thread\n");
io = ioproc();
USED(arg);
diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c
index bf7afa3f..6d1d9d17 100644
--- a/src/cmd/plumb/plumber.c
+++ b/src/cmd/plumb/plumber.c
@@ -69,19 +69,8 @@ threadmain(int argc, char *argv[])
rules = readrules(plumbfile, fd);
close(fd);
- /*
- * Start all processes and threads from other proc
- * so we (main pid) can return to user.
- */
if(dofork)
- switch(fork()){
- case -1:
- sysfatal("fork: %r");
- case 0:
- break;
- default:
- _exit(0);
- }
+ threaddaemonize();
printerrors = 0;
makeports(rules);