diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-16 23:54:46 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-16 23:54:46 +0100 |
commit | a277506a64404e6c4472ff89c944c4f353db1c33 (patch) | |
tree | 168015ae951c51bcb0295c2ebc241f168001a135 | |
parent | c2788f88f430da8ae5fb5f293b13fc2b167ea2fe (diff) | |
download | busybox-w32-a277506a64404e6c4472ff89c944c4f353db1c33.tar.gz busybox-w32-a277506a64404e6c4472ff89c944c4f353db1c33.tar.bz2 busybox-w32-a277506a64404e6c4472ff89c944c4f353db1c33.zip |
shell: add comments about SIGINT-related problems
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 13 | ||||
-rw-r--r-- | shell/shell_common.c | 1 |
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) | |||
664 | /* | 664 | /* |
665 | * Called when a SIGINT is received. (If the user specifies | 665 | * Called when a SIGINT is received. (If the user specifies |
666 | * that SIGINT is to be trapped or ignored using the trap builtin, then | 666 | * that SIGINT is to be trapped or ignored using the trap builtin, then |
667 | * this routine is not called.) Suppressint is nonzero when interrupts | 667 | * this routine is not called.) suppress_int is nonzero when interrupts |
668 | * are held using the INT_OFF macro. (The test for iflag is just | 668 | * are held using the INT_OFF macro. (The test for iflag is just |
669 | * defensive programming.) | 669 | * defensive programming.) |
670 | */ | 670 | */ |
@@ -695,13 +695,12 @@ raise_interrupt(void) | |||
695 | } while (0) | 695 | } while (0) |
696 | #endif | 696 | #endif |
697 | 697 | ||
698 | static IF_ASH_OPTIMIZE_FOR_SIZE(inline) void | 698 | static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void |
699 | int_on(void) | 699 | int_on(void) |
700 | { | 700 | { |
701 | barrier(); | 701 | barrier(); |
702 | if (--suppress_int == 0 && pending_int) { | 702 | if (--suppress_int == 0 && pending_int) |
703 | raise_interrupt(); | 703 | raise_interrupt(); |
704 | } | ||
705 | } | 704 | } |
706 | #if DEBUG_INTONOFF | 705 | #if DEBUG_INTONOFF |
707 | # define INT_ON do { \ | 706 | # define INT_ON do { \ |
@@ -711,7 +710,7 @@ int_on(void) | |||
711 | #else | 710 | #else |
712 | # define INT_ON int_on() | 711 | # define INT_ON int_on() |
713 | #endif | 712 | #endif |
714 | static IF_ASH_OPTIMIZE_FOR_SIZE(inline) void | 713 | static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void |
715 | force_int_on(void) | 714 | force_int_on(void) |
716 | { | 715 | { |
717 | barrier(); | 716 | barrier(); |
@@ -10785,6 +10784,10 @@ preadfd(void) | |||
10785 | # endif | 10784 | # endif |
10786 | reinit_unicode_for_ash(); | 10785 | reinit_unicode_for_ash(); |
10787 | again: | 10786 | again: |
10787 | //BUG: not in INT_OFF/INT_ON section - SIGINT et al would longjmp out of read_line_input()! | ||
10788 | //This would cause a memory leak in interactive shell | ||
10789 | //(repeated internal allocations in read_line_input): | ||
10790 | // (while kill -INT $$; do :; done) & | ||
10788 | nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ); | 10791 | nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ); |
10789 | if (nr == 0) { | 10792 | if (nr == 0) { |
10790 | /* ^C pressed, "convert" to SIGINT */ | 10793 | /* ^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) | |||
196 | */ | 196 | */ |
197 | errno = 0; | 197 | errno = 0; |
198 | pfd[0].events = POLLIN; | 198 | pfd[0].events = POLLIN; |
199 | //TODO race with a signal arriving just before the poll! | ||
199 | if (poll(pfd, 1, timeout) <= 0) { | 200 | if (poll(pfd, 1, timeout) <= 0) { |
200 | /* timed out, or EINTR */ | 201 | /* timed out, or EINTR */ |
201 | err = errno; | 202 | err = errno; |