aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/plumb/plumber.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-28 23:20:54 +0000
committerrsc <devnull@localhost>2004-12-28 23:20:54 +0000
commitdf49b303431ef0b62c4f6fc4d790a1fd2d2f7e77 (patch)
treecacb092e5010bb07fec9eb9ee63c14c01a23b50c /src/cmd/plumb/plumber.c
parentddd8916a0e04baee417c2f71f73e45df9acf7c72 (diff)
downloadplan9port-df49b303431ef0b62c4f6fc4d790a1fd2d2f7e77.tar.gz
plan9port-df49b303431ef0b62c4f6fc4d790a1fd2d2f7e77.tar.bz2
plan9port-df49b303431ef0b62c4f6fc4d790a1fd2d2f7e77.zip
be like plan 9 plumber
Diffstat (limited to 'src/cmd/plumb/plumber.c')
-rw-r--r--src/cmd/plumb/plumber.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c
index a05fe612..968953d6 100644
--- a/src/cmd/plumb/plumber.c
+++ b/src/cmd/plumb/plumber.c
@@ -26,11 +26,24 @@ 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;
int volatile dofork;
+ Channel *c;
progname = "plumber";
dofork = 1;
@@ -73,9 +86,15 @@ threadmain(int argc, char *argv[])
if(dofork)
threaddaemonize();
- printerrors = 0;
- makeports(rules);
- startfsys();
+ /*
+ * 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);
}
void