mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-19 19:44:35 +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);
|
nbytes = read(dd->infd, buffer, dd->sectsize - dd->nbytes);
|
||||||
if (nbytes < 0)
|
if (nbytes < 0)
|
||||||
{
|
{
|
||||||
|
if (errno == EINTR)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
FAR struct nsh_vtbl_s *vtbl = dd->vtbl;
|
FAR struct nsh_vtbl_s *vtbl = dd->vtbl;
|
||||||
nsh_error(vtbl, g_fmtcmdfailed, g_dd, "read", NSH_ERRNO);
|
nsh_error(vtbl, g_fmtcmdfailed, g_dd, "read", NSH_ERRNO);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@@ -134,7 +139,7 @@ static int dd_read(FAR struct dd_s *dd)
|
|||||||
dd->nbytes += nbytes;
|
dd->nbytes += nbytes;
|
||||||
buffer += nbytes;
|
buffer += nbytes;
|
||||||
}
|
}
|
||||||
while (dd->nbytes < dd->sectsize && nbytes > 0);
|
while (dd->nbytes < dd->sectsize && nbytes != 0);
|
||||||
|
|
||||||
dd->eof |= (dd->nbytes == 0);
|
dd->eof |= (dd->nbytes == 0);
|
||||||
return OK;
|
return OK;
|
||||||
|
Reference in New Issue
Block a user