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

Stam, Michel [FINT] M.Stam at fugro.nl
Mon Oct 6 10:46:09 EDT 2014


Ok John,

Thanks

Kind regards,

Michel Stam

-----Original Message-----
From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org] On
Behalf Of John Crispin
Sent: Monday, October 06, 2014 16:44 PM
To: openwrt-devel at lists.openwrt.org
Subject: Re: [OpenWrt-Devel] [PATCH procd 2/8] Log startup/shutdown
toconsole



On 06/10/2014 15:12, Stam, Michel [FINT] wrote:
> Hello John,
> 
> A single printf would not work; it seems to work if it is a fprintf to

> stderr. The problem with regular printfs is that if someone presses 
> CTRL-S /scroll lock on the console, they can effectively block procd 
> that way, because printf will block when writing to a blocked tty.
> 
> Also, this would require my other patch at 
> http://patchwork.openwrt.org/patch/6364/, otherwise stderr may be 
> blocked as well.
> 
> Please let me know if this is an acceptable solution, I will then 
> rework the patch this way.

lets use 6364 + a fprintf(sdterr, "")

i will use the patches you sent as a basis and do the missing bits.















> 
> Kind regards,
> 
> Michel Stam







> 
> -----Original Message----- From: openwrt-devel 
> [mailto:openwrt-devel-bounces at lists.openwrt.org] On Behalf Of John 
> Crispin Sent: Friday, October 03, 2014 18:30 PM To:
> openwrt-devel at lists.openwrt.org Subject: Re: [OpenWrt-Devel] [PATCH 
> procd 2/8] Log startup/shutdown toconsole
> 
> 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
> _______________________________________________ openwrt-devel mailing 
> list openwrt-devel at lists.openwrt.org 
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
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