From ebc19a60ff5d32750384f5a99a315d5533d62058 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Fri, 8 Nov 2024 16:45:19 +0800 Subject: [PATCH] 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 --- nshlib/nsh_fscmds.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index bf23beabe1..88f76d1ee3 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -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); }