be like plan 9 plumber
diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c
index a05fe61..968953d 100644
--- a/src/cmd/plumb/plumber.c
+++ b/src/cmd/plumb/plumber.c
@@ -26,11 +26,24 @@
}
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 @@
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