Skip to content

Commit ebc19a6

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

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

nshlib/nsh_fscmds.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,10 +802,19 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
802802
while (true)
803803
{
804804
ret = nsh_read(vtbl, buf, BUFSIZ);
805-
if (ret <= 0)
805+
if (ret == 0)
806806
{
807807
break;
808808
}
809+
else if (ret < 0)
810+
{
811+
if (errno == EINTR)
812+
{
813+
continue;
814+
}
815+
816+
break;
817+
}
809818

810819
nsh_write(vtbl, buf, ret);
811820
}

0 commit comments

Comments
 (0)