mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-18 00:11:20 +08:00
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 <wangjianyu3@xiaomi.com>
This commit is contained in:
@@ -126,6 +126,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;
|
||||
}
|
||||
|
||||
FAR struct nsh_vtbl_s *vtbl = dd->vtbl;
|
||||
nsh_error(vtbl, g_fmtcmdfailed, g_dd, "read", NSH_ERRNO);
|
||||
return ERROR;
|
||||
@@ -134,7 +139,7 @@ static int dd_read(FAR struct dd_s *dd)
|
||||
dd->nbytes += nbytes;
|
||||
buffer += nbytes;
|
||||
}
|
||||
while (dd->nbytes < dd->sectsize && nbytes > 0);
|
||||
while (dd->nbytes < dd->sectsize && nbytes != 0);
|
||||
|
||||
dd->eof |= (dd->nbytes == 0);
|
||||
return OK;
|
||||
|
Reference in New Issue
Block a user