commit b0aecb4ba5c3d7df6589c01f5a7c0427f5a75305 from: Jason Felice via: Dan Cross date: Tue Oct 29 14:07:10 2019 UTC plumber: add -f (foreground) option (#288) In MacOS, services run by launchd must run in the foreground, since launchd manages forking and other resources. commit - 1309450668aa571dee97f4373f9555b4fddcf1aa commit + b0aecb4ba5c3d7df6589c01f5a7c0427f5a75305 blob - 0dfe68bb8b727ef0433ba7f604b0c64a0b91374d blob + 88801eb4d27054f4f9c17963aaac21f425f553da --- man/man4/plumber.4 +++ man/man4/plumber.4 @@ -4,6 +4,9 @@ plumber \- file system for interprocess messaging .SH SYNOPSIS .B plumber [ +.B -f +] +[ .B -p .I plumbing ] @@ -23,7 +26,7 @@ in the format of Its services are posted via .IR 9pserve (4) as -.BR plumb . +.BR plumb , and consist of two pre-defined files, .B plumb/send @@ -95,6 +98,10 @@ Thus the rule set may be edited dynamically with a tra However, ports are never deleted dynamically; if a new set of rules does not include a port that was defined in earlier rules, that port will still exist (although no new messages will be delivered there). +.PP +The +.B -f +option causes the process to run in the foreground. .SH FILES .TF $HOME/lib/plumbing .TP blob - 515426748efe2b15b33895daa6603a9fc559c261 blob + 63106fcdbd6b5e29f81e44c33bb4175bfe5077b8 --- src/cmd/plumb/fsys.c +++ src/cmd/plumb/fsys.c @@ -186,7 +186,7 @@ getclock(void) } void -startfsys(void) +startfsys(int foreground) { int p[2]; @@ -199,7 +199,10 @@ startfsys(void) if(post9pservice(p[1], "plumb", nil) < 0) sysfatal("post9pservice plumb: %r"); close(p[1]); - proccreate(fsysproc, nil, Stack); + if(foreground) + fsysproc(nil); + else + proccreate(fsysproc, nil, Stack); } static void blob - 2debf49baa83d54a752a76d2c487139e69428453 blob + c99282f02da0c4a939fb49ae3ec32c49b18fc5a5 --- src/cmd/plumb/plumber.c +++ src/cmd/plumb/plumber.c @@ -7,6 +7,7 @@ #include "plumber.h" int debug; +int foreground=0; char *plumbfile; char *user; char *home; @@ -37,6 +38,9 @@ threadmain(int argc, char *argv[]) case 'd': debug = 1; break; + case 'f': + foreground = 1; + break; case 'p': plumbfile = ARGF(); break; @@ -69,7 +73,7 @@ threadmain(int argc, char *argv[]) */ printerrors = 0; makeports(rules); - startfsys(); + startfsys(foreground); threadexits(nil); } blob - c8f3081660300160dec85b67d642bcb12d96dbac blob + 44700559ba3e0ec188f26406931d544ff050a2f7 --- src/cmd/plumb/plumber.h +++ src/cmd/plumb/plumber.h @@ -72,7 +72,7 @@ void* emalloc(long); void* erealloc(void*, long); char* estrdup(char*); Ruleset** readrules(char*, int); -void startfsys(void); +void startfsys(int); Exec* matchruleset(Plumbmsg*, Ruleset*); void freeexec(Exec*); char* startup(Ruleset*, Exec*);