diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-13 15:09:39 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-13 15:09:39 +0200 |
commit | 8e11ff283f1e7c36b23e6e52c2ab0ca12a7713f9 (patch) | |
tree | 21ae354f7121d196046b6b9c36a18232afb38e43 /sys/src/cmd/cwfs/con.c | |
parent | 53f5bdfd06cce8093de005b8d706b752d3567cfa (diff) |
cwfs: make /srv/cwfs.cmd redable to receive command output
before, cwfs would print everything to /dev/cons. this change
will redirect the output of commands to the /srv/cwfs.cmd pipe
so one can use:
con -C /srv/cwfs.cmd
and not have the fish for the output in /dev/kmesg.
use standard error (/dev/cons) for unsolicited messages as
there is not always a reader on the command file.
Diffstat (limited to 'sys/src/cmd/cwfs/con.c')
-rw-r--r-- | sys/src/cmd/cwfs/con.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/sys/src/cmd/cwfs/con.c b/sys/src/cmd/cwfs/con.c index 11fcadf8d..61ab25806 100644 --- a/sys/src/cmd/cwfs/con.c +++ b/sys/src/cmd/cwfs/con.c @@ -26,6 +26,9 @@ consserve(void) break; } + /* switch console output to the cmd pipe */ + dup(0, 1); + newproc(consserve1, 0, "con"); } @@ -35,14 +38,9 @@ consserve1(void *) { char *conline; - for (;;) { - do { - if ((conline = Brdline(&bin, '\n')) != nil) { - conline[Blinelen(&bin)-1] = '\0'; - print("%s: %s\n", service, conline); - cmd_exec(conline); - } - } while (conline != nil); + while(conline = Brdline(&bin, '\n')){ + conline[Blinelen(&bin)-1] = '\0'; + cmd_exec(conline); } } @@ -112,7 +110,6 @@ cmd_exec(char *arg) for(i=0; s=command[i].arg0; i++) if(strcmp(argv[0], s) == 0) { (*command[i].func)(argc, argv); - prflush(); return; } print("cmd_exec: unknown command: %s\n", argv[0]); @@ -319,7 +316,6 @@ cmd_who(int argc, char *argv[]) if(cp->whoprint) cp->whoprint(cp); print("\n"); - prflush(); } if(c > 0) print("%d chans not listed\n", c); @@ -353,7 +349,6 @@ cmd_sync(int, char *[]) wlock(&mainlock); /* sync */ sync("command"); wunlock(&mainlock); - print("\n"); } static void @@ -371,7 +366,6 @@ cmd_help(int argc, char *argv[]) } found: print("\t%s %s\n", arg, command[i].help); - prflush(); } } @@ -696,16 +690,14 @@ void cmd_noauth(int, char *[]) { noauth = !noauth; - if(noauth) - print("authentication is DISABLED\n"); + print("authentication %s\n", noauth ? "disabled" : "enabled"); } void cmd_noattach(int, char *[]) { noattach = !noattach; - if(noattach) - print("attaches are DISABLED\n"); + print("attach %s\n", noattach ? "disabled" : "enabled"); } void @@ -731,7 +723,6 @@ cmd_files(int, char *[]) for(cp = chans; cp; cp = cp->next) if(cp->nfile) { print("%3d: %5d\n", cp->chan, cp->nfile); - prflush(); n += cp->nfile; } print("%ld out of %ld files used\n", n, conf.nfile); |