This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new ebc19a60f nshlib/cmd_cat: Retry if nsh_read was interrupted by a signal
ebc19a60f is described below

commit ebc19a60ff5d32750384f5a99a315d5533d62058
Author: wangjianyu3 <[email protected]>
AuthorDate: Fri Nov 8 16:45:19 2024 +0800

    nshlib/cmd_cat: Retry if nsh_read was interrupted by a signal
    
    When read from stdio of child process through pipe, SIGCHLD received if 
child exits.
    
    Signed-off-by: wangjianyu3 <[email protected]>
---
 nshlib/nsh_fscmds.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c
index bf23beabe..88f76d1ee 100644
--- a/nshlib/nsh_fscmds.c
+++ b/nshlib/nsh_fscmds.c
@@ -802,10 +802,19 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, FAR 
char **argv)
       while (true)
         {
           ret = nsh_read(vtbl, buf, BUFSIZ);
-          if (ret <= 0)
+          if (ret == 0)
             {
               break;
             }
+          else if (ret < 0)
+            {
+              if (errno == EINTR)
+                {
+                  continue;
+                }
+
+              break;
+            }
 
           nsh_write(vtbl, buf, ret);
         }

Reply via email to