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

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

commit b608dd0e3f9ba23ebed6635699b68b8da5c5d124
Author: dongjiuzhu1 <dongjiuz...@xiaomi.com>
AuthorDate: Sat Apr 12 18:37:49 2025 +0800

    system/dd: align nshlib/cmd_dd
    
        nshlib/cmd_dd: Retry if read() was interrupted
    
        Without this patch
    
          nsh> ls /etc/group | dd | dd
          sh [13:100]
          sh [14:100]
          nsh: dd: read failed: 4
          nsh>
    
        Signed-off-by: wangjianyu3 <wangjian...@xiaomi.com>
    
    Signed-off-by: dongjiuzhu1 <dongjiuz...@xiaomi.com>
---
 system/dd/dd_main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/system/dd/dd_main.c b/system/dd/dd_main.c
index 744f3dbba..b92c44233 100644
--- a/system/dd/dd_main.c
+++ b/system/dd/dd_main.c
@@ -135,6 +135,11 @@ static int dd_read(FAR struct dd_s *dd)
       nbytes = read(dd->infd, buffer, dd->sectsize - dd->nbytes);
       if (nbytes < 0)
         {
+          if (errno == EINTR)
+            {
+              continue;
+            }
+
           fprintf(stderr, "%s: failed to read: %s\n", g_dd, strerror(errno));
           return ERROR;
         }
@@ -147,7 +152,7 @@ static int dd_read(FAR struct dd_s *dd)
           break;
         }
     }
-  while (dd->nbytes < dd->sectsize && nbytes > 0);
+  while (dd->nbytes < dd->sectsize && nbytes != 0);
 
   return OK;
 }

Reply via email to