summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-01-16 23:54:46 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2022-01-16 23:54:46 +0100
commita277506a64404e6c4472ff89c944c4f353db1c33 (patch)
tree168015ae951c51bcb0295c2ebc241f168001a135 /shell
parentc2788f88f430da8ae5fb5f293b13fc2b167ea2fe (diff)
downloadbusybox-a277506a64404e6c4472ff89c944c4f353db1c33.tar.gz
shell: add comments about SIGINT-related problems
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c13
-rw-r--r--shell/shell_common.c1
2 files changed, 9 insertions, 5 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ca5c755b6..086773dd7 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -664,7 +664,7 @@ raise_exception(int e)
/*
* Called when a SIGINT is received. (If the user specifies
* that SIGINT is to be trapped or ignored using the trap builtin, then
- * this routine is not called.) Suppressint is nonzero when interrupts
+ * this routine is not called.) suppress_int is nonzero when interrupts
* are held using the INT_OFF macro. (The test for iflag is just
* defensive programming.)
*/
@@ -695,13 +695,12 @@ raise_interrupt(void)
} while (0)
#endif
-static IF_ASH_OPTIMIZE_FOR_SIZE(inline) void
+static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void
int_on(void)
{
barrier();
- if (--suppress_int == 0 && pending_int) {
+ if (--suppress_int == 0 && pending_int)
raise_interrupt();
- }
}
#if DEBUG_INTONOFF
# define INT_ON do { \
@@ -711,7 +710,7 @@ int_on(void)
#else
# define INT_ON int_on()
#endif
-static IF_ASH_OPTIMIZE_FOR_SIZE(inline) void
+static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void
force_int_on(void)
{
barrier();
@@ -10785,6 +10784,10 @@ preadfd(void)
# endif
reinit_unicode_for_ash();
again:
+//BUG: not in INT_OFF/INT_ON section - SIGINT et al would longjmp out of read_line_input()!
+//This would cause a memory leak in interactive shell
+//(repeated internal allocations in read_line_input):
+// (while kill -INT $$; do :; done) &
nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ);
if (nr == 0) {
/* ^C pressed, "convert" to SIGINT */
diff --git a/shell/shell_common.c b/shell/shell_common.c
index 2e36d9208..13163acdf 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -196,6 +196,7 @@ shell_builtin_read(struct builtin_read_params *params)
*/
errno = 0;
pfd[0].events = POLLIN;
+//TODO race with a signal arriving just before the poll!
if (poll(pfd, 1, timeout) <= 0) {
/* timed out, or EINTR */
err = errno;