Hi Peng, >From http://www.cplusplus.com/reference/cstdio/fwrite/ fwrite return zero to indicate the error, the detailed info could get from errno. So the right change is modified the error handling code in nsh_catfile, not the return type of fwrite.
Thanks Xiang On Tue, Dec 24, 2019 at 9:48 AM wei peng <alvin.pe...@gmail.com> wrote: > > hi David, > > Thanks for your reply. > > Yes...i know the interface interface is standard,so what i had changed in > codes just repaired the problem.perhaps i should describe the problem in > detail. > > > I entering "dmesg" on both terminals,because of the “CONFIG_IOB_DEBUG” is > enable so both of terminals will show messages continuously. > Then close one of them,and the other one will be frozen,after that i cannot > connect the borad (via usart or telnet).but i am sure the systerm is work > on. > > > I found the "dmesg" command call a function named "int nsh_catfile()",and > in this function,the logic is simple (read message from ramlog and write it > to terminals). > when write it to terminals ,it will call "size_t fwrite()"function, As you > see the size_t is unsigned cannot be negative. that is the problem. > i think if the terminal is close,the "size_t fwrite()"function should > return a negative number,and the nsh_catfile should be broken. > > BR, > > wei peng > > David Sidrane <davi...@apache.org> 于2019年12月23日周一 下午5:36写道: > > > Hi wei peng > > See below. > > > > On 2019/12/23 07:41:40, wei peng <alvin.pe...@gmail.com> wrote: > > > hi~ > > > I connected the target board to terminal via "telnet" , in some cases > > > the terminal will be frozen. Here are detailed steps: > > > > > > 1. Enable "CONFIG_IOB_DEBUG"[necessary]. > > > 2. New two terminals and connect to target board via "telnet". > > > 3. Input "dmesg" command,and the terminal will show information > > > *continuously*.[two terminals are same][necessary] > > > 4. Close one of the terminals,and the other one will be frozen.but > > the > > > system is work on. > > > > > > I debug the system and repaired the bug,the file named commit.txt is > > > detailed steps. > > > BR, > > > > > > wei peng > > > > The interface is dictated by the OpenGroup stands [1] > > [1] https://pubs.opengroup.org/onlinepubs/009695399/functions/fwrite.html > > > > So that can not be changed. > > > > There must be a root cause related to what you are doing or a bug in the > > system. Check the configuration (compare it to other telnet board configs). > > > > Are you Entering dmesg on both terminals or on one and it is showing up > > the 2 terminals? > > > > David > > > >