From df49b303431ef0b62c4f6fc4d790a1fd2d2f7e77 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 28 Dec 2004 23:20:54 +0000 Subject: be like plan 9 plumber --- src/cmd/plumb/plumber.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/cmd/plumb/plumber.c') 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 @@ -25,12 +25,25 @@ makeports(Ruleset *rules[]) addport(rules[i]->port); } +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 -- cgit v1.2.3