[OpenWrt-Devel] [PATCH procd 2/8] Log startup/shutdown to console

John Crispin blogic at openwrt.org
Fri Oct 3 12:29:51 EDT 2014


stdout is already /dev/console i think and removing the messages on
shutdown also removes them in all other cases from the log.

should adding a single printf("%s", str); not work ?

On 02/10/2014 14:56, Michel Stam wrote:
> procd has the habit of logging startup/shutdown via rcS to syslog,
> which is pointless in case of a shutdown, and unlikely to be
> complete on a startup (as syslog is not running). Write to
> /dev/console instead.
> 
> Signed-off-by: Michel Stam <m.stam at fugro.nl> --- rcS.c | 10
> ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/rcS.c b/rcS.c index 4545621..e01fc49 100644 ---
> a/rcS.c +++ b/rcS.c @@ -18,10 +18,11 @@
> 
> #include <libubox/uloop.h> #include <libubox/runqueue.h> +#include
> <fcntl.h> #include <stdlib.h> #include <stdio.h> #include
> <unistd.h> - +#include <paths.h> #include <sys/types.h> #include
> <sys/stat.h> #include <glob.h> @@ -43,8 +44,9 @@ struct initd { 
> static void pipe_cb(struct ustream *s, int bytes) { char *newline,
> *str; -	int len; +	int len, console_fd;
> 
> +	console_fd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY |
> O_NONBLOCK); do { str = ustream_get_read_buf(s, NULL); if (!str) @@
> -52,11 +54,11 @@ static void pipe_cb(struct ustream *s, int bytes) 
> newline = strchr(str, '\n'); if (!newline) break; -		*newline = 0; 
> len = newline + 1 - str; -		syslog(0, "%s", str); +
> write(console_fd, str, len); ustream_consume(s, len); } while (1); 
> +	close(console_fd); }
> 
> static void q_initd_run(struct runqueue *q, struct runqueue_task
> *t)
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list