aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/plumb
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/plumb')
-rw-r--r--src/cmd/plumb/fsys.c6
-rw-r--r--src/cmd/plumb/match.c4
-rw-r--r--src/cmd/plumb/mkfile2
-rw-r--r--src/cmd/plumb/plumb.c5
-rw-r--r--src/cmd/plumb/plumber.c30
5 files changed, 21 insertions, 26 deletions
diff --git a/src/cmd/plumb/fsys.c b/src/cmd/plumb/fsys.c
index 912e5ca0..4776d127 100644
--- a/src/cmd/plumb/fsys.c
+++ b/src/cmd/plumb/fsys.c
@@ -195,7 +195,7 @@ startfsys(void)
if(post9pservice(p[1], "plumb") < 0)
sysfatal("post9pservice plumb: %r");
close(p[1]);
- proccreate(fsysproc, nil, Stack);
+ threadcreate(fsysproc, nil, Stack);
}
static void
@@ -213,14 +213,14 @@ fsysproc(void *v)
if(buf == nil)
error("malloc failed: %r");
qlock(&readlock);
- n = read9pmsg(srvfd, buf, messagesize);
+ n = threadread9pmsg(srvfd, buf, messagesize);
if(n <= 0){
if(n < 0)
error("i/o error on server channel");
threadexitsall("unmounted");
}
if(readlock.head == nil) /* no other processes waiting to read; start one */
- proccreate(fsysproc, nil, Stack);
+ threadcreate(fsysproc, nil, Stack);
qunlock(&readlock);
if(t == nil)
t = emalloc(sizeof(Fcall));
diff --git a/src/cmd/plumb/match.c b/src/cmd/plumb/match.c
index dc1abbb1..5a4cd88c 100644
--- a/src/cmd/plumb/match.c
+++ b/src/cmd/plumb/match.c
@@ -431,7 +431,7 @@ execproc(void *v)
av = v;
stackargv(av, args, argc);
free(av);
- procexec(nil, fd, args[0], args);
+ threadexec(nil, fd, args[0], args);
threadexits("can't exec");
}
@@ -458,6 +458,6 @@ Found:
argv = buildargv(rs->act[i]->arg, e);
if(argv[0] == nil)
return "empty argument list";
- proccreate(execproc, argv, EXECSTACK);
+ threadcreate(execproc, argv, EXECSTACK);
return nil;
}
diff --git a/src/cmd/plumb/mkfile b/src/cmd/plumb/mkfile
index 6550387f..81494416 100644
--- a/src/cmd/plumb/mkfile
+++ b/src/cmd/plumb/mkfile
@@ -14,4 +14,4 @@ $PLUMB: $HFILES
$O.plumb: $PLUMB
$O.plumber: $PLUMBER
-LDFLAGS=$LDFLAGS -lplumb -lfs -lmux -lthread -lregexp9 -l9 -lbio -lfmt -lutf
+LDFLAGS=$LDFLAGS -lplumb -lfs -lmux -lthread -lregexp9 -lbio -l9
diff --git a/src/cmd/plumb/plumb.c b/src/cmd/plumb/plumb.c
index e0cff912..a10f2c37 100644
--- a/src/cmd/plumb/plumb.c
+++ b/src/cmd/plumb/plumb.c
@@ -1,6 +1,7 @@
#include <u.h>
#include <libc.h>
#include <plumb.h>
+#include <thread.h>
char *plumbfile = nil;
Plumbmsg m;
@@ -36,7 +37,7 @@ gather(void)
}
void
-main(int argc, char *argv[])
+threadmain(int argc, char *argv[])
{
char buf[1024], *p;
int fd, i, input;
@@ -115,5 +116,5 @@ main(int argc, char *argv[])
exits("error");
}
}
- exits(nil);
+ threadexitsall(nil);
}
diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c
index 424469f2..ae45f933 100644
--- a/src/cmd/plumb/plumber.c
+++ b/src/cmd/plumb/plumber.c
@@ -26,23 +26,10 @@ makeports(Ruleset *rules[])
}
void
-mainproc(void *v)
-{
- Channel *c;
-
- c = v;
- printerrors = 0;
- makeports(rules);
- startfsys();
- sendp(c, nil);
-}
-
-void
threadmain(int argc, char *argv[])
{
char buf[512];
int fd;
- Channel *c;
progname = "plumber";
@@ -79,11 +66,18 @@ threadmain(int argc, char *argv[])
* Start all processes and threads from other proc
* so we (main pid) can return to user.
*/
- c = chancreate(sizeof(void*), 0);
- proccreate(mainproc, c, 8192);
- recvp(c);
- chanfree(c);
- threadexits(nil);
+ switch(fork()){
+ case -1:
+ sysfatal("fork: %r");
+ case 0:
+ break;
+ default:
+ _exit(0);
+ }
+
+ printerrors = 0;
+ makeports(rules);
+ startfsys();
}
void