Skip to content

Commit 27b5021

Browse files
JianyuWang0623xiaoxiang781216
authored andcommitted
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>
1 parent ebc19a6 commit 27b5021

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

nshlib/nsh_ddcmd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ static int dd_read(FAR struct dd_s *dd)
126126
nbytes = read(dd->infd, buffer, dd->sectsize - dd->nbytes);
127127
if (nbytes < 0)
128128
{
129+
if (errno == EINTR)
130+
{
131+
continue;
132+
}
133+
129134
FAR struct nsh_vtbl_s *vtbl = dd->vtbl;
130135
nsh_error(vtbl, g_fmtcmdfailed, g_dd, "read", NSH_ERRNO);
131136
return ERROR;
@@ -134,7 +139,7 @@ static int dd_read(FAR struct dd_s *dd)
134139
dd->nbytes += nbytes;
135140
buffer += nbytes;
136141
}
137-
while (dd->nbytes < dd->sectsize && nbytes > 0);
142+
while (dd->nbytes < dd->sectsize && nbytes != 0);
138143

139144
dd->eof |= (dd->nbytes == 0);
140145
return OK;

0 commit comments

Comments
 (0)