Skip to content

Commit

Permalink
nshlib/cmd_cat: Retry if nsh_read was interrupted by a signal
Browse files Browse the repository at this point in the history
When read from stdio of child process through pipe, SIGCHLD received if child exits.

Signed-off-by: wangjianyu3 <[email protected]>
  • Loading branch information
JianyuWang0623 authored and xiaoxiang781216 committed Nov 10, 2024
1 parent e2a2133 commit ebc19a6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nshlib/nsh_fscmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit ebc19a6

Please sign in to comment.