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 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3 2024-11-08 16:45:19 +08:00 committed by Xiang Xiao
parent e2a21337ac
commit ebc19a60ff

View file

@ -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);
}