aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2010-05-29 09:44:53 +1000
committermaximilian attems <max@stro.at>2011-06-03 18:44:12 +0200
commitbd5fc97084fe1e038f50e3da435d16936bc4d6db (patch)
treeb57ee1f001345fc34e4a9f5c2d08e07e78910139
parentb47bda0656e7ebf2cbb763f03455a407800063ea (diff)
downloadklibc-bd5fc97084fe1e038f50e3da435d16936bc4d6db.tar.gz
[klibc] [BUILTIN] Continue after EINTR in read(1) with no pending
signals The recent introduction of SIGCHLD trapping broke read(1) as each SIGCHLD may cause read(1) to return prematurely. Now if we did have a trap for SIGCHLD read(1) should actually do this. However, returning when SIGCHLD isn't trapped is wrong. This patch fixes this by checking for EINTR and pendingsigs in read(1). Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> [ merge fixups -maks ] Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/dash/miscbltin.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/usr/dash/miscbltin.c b/usr/dash/miscbltin.c
index 50da2529c1319..c6c5d55c531d5 100644
--- a/usr/dash/miscbltin.c
+++ b/usr/dash/miscbltin.c
@@ -58,6 +58,7 @@
#include "main.h"
#include "expand.h"
#include "parser.h"
+#include "trap.h"
#undef rflag
@@ -213,9 +214,16 @@ readcmd(int argc, char **argv)
break; /* Timeout! */
}
}
- if (read(0, &c, 1) != 1) {
- status = 1;
+ switch (read(0, &c, 1)) {
+ case 1:
break;
+ default:
+ if (errno == EINTR && !pendingsigs)
+ continue;
+ /* fall through */
+ case 0:
+ status = 1;
+ goto out;
}
if (c == '\0')
continue;
@@ -236,6 +244,7 @@ put:
resetbs:
backslash = 0;
}
+out:
STACKSTRNUL(p);
readcmd_handle_line(stackblock(), ap, p + 1 - (char *)stackblock());
return status;