From 6eac2079be6efd42102e62105c025af9143e6d6d Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Fri, 13 Nov 2020 19:43:44 -0800 Subject: [PATCH] More control over output streams Added options -A[filename] and -S[filename] to allow more control over which output streams go where (for mlong and his troubles with running ircd via systemd). -A controls "all messages" either sending all to stdout or the specified filename. This override the automatic suppression of the console output stream when run without a controlling TTY. -S controls "status message" (includes non-error level log messages), either sending the status messages to stdout or the specified filename. This also overrides the automatic suppression of the console output stream when run without a controlling TTY. --- src/sbbs3/jsexec.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/sbbs3/jsexec.c b/src/sbbs3/jsexec.c index cfe931314d..85a57f3eee 100644 --- a/src/sbbs3/jsexec.c +++ b/src/sbbs3/jsexec.c @@ -148,8 +148,12 @@ void usage(FILE* fp) " -i<path_list> set load() comma-sep search path list (default=\"%s\")\n" " -f use non-buffered stream for console messages\n" " -a append instead of overwriting message output files\n" + " -A send all message to stdout\n" + " -A<filename> send all message to file instead of stdout/stderr\n" " -e<filename> send error messages to file in addition to stderr\n" " -o<filename> send console messages to file instead of stdout\n" + " -S<filename> send status messages to file instead of stderr\n" + " -S send status messages to stdout\n" " -n send status messages to %s instead of stderr\n" " -q send console messages to %s instead of stdout\n" " -v display version details and exit\n" @@ -1306,6 +1310,22 @@ int main(int argc, char **argv, char** env) case 'a': omode="a"; break; + case 'A': + if (errfp != stderr) + fclose(errfp); + if(*p == '\0') { + errfp = stdout; + confp = stdout; + statfp = stdout; + } else { + if((errfp = fopen(p, omode)) == NULL) { + perror(p); + return(do_bail(1)); + } + statfp = errfp; + confp = errfp; + } + break; case 'C': change_cwd = FALSE; break; @@ -1329,6 +1349,16 @@ int main(int argc, char **argv, char** env) case 'l': loop=TRUE; break; + case 'S': + if(*p == '\0') + statfp = stdout; + else { + if((statfp = fopen(p,omode))==NULL) { + perror(p); + return(do_bail(1)); + } + } + break; case 'n': statfp=nulfp; break; -- GitLab