shell: add comments about SIGINT-related problems
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
c2788f88f4
commit
a277506a64
13
shell/ash.c
13
shell/ash.c
@ -664,7 +664,7 @@ raise_exception(int e)
|
|||||||
/*
|
/*
|
||||||
* Called when a SIGINT is received. (If the user specifies
|
* Called when a SIGINT is received. (If the user specifies
|
||||||
* that SIGINT is to be trapped or ignored using the trap builtin, then
|
* 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
|
* are held using the INT_OFF macro. (The test for iflag is just
|
||||||
* defensive programming.)
|
* defensive programming.)
|
||||||
*/
|
*/
|
||||||
@ -695,13 +695,12 @@ raise_interrupt(void)
|
|||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static IF_ASH_OPTIMIZE_FOR_SIZE(inline) void
|
static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void
|
||||||
int_on(void)
|
int_on(void)
|
||||||
{
|
{
|
||||||
barrier();
|
barrier();
|
||||||
if (--suppress_int == 0 && pending_int) {
|
if (--suppress_int == 0 && pending_int)
|
||||||
raise_interrupt();
|
raise_interrupt();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if DEBUG_INTONOFF
|
#if DEBUG_INTONOFF
|
||||||
# define INT_ON do { \
|
# define INT_ON do { \
|
||||||
@ -711,7 +710,7 @@ int_on(void)
|
|||||||
#else
|
#else
|
||||||
# define INT_ON int_on()
|
# define INT_ON int_on()
|
||||||
#endif
|
#endif
|
||||||
static IF_ASH_OPTIMIZE_FOR_SIZE(inline) void
|
static IF_NOT_ASH_OPTIMIZE_FOR_SIZE(inline) void
|
||||||
force_int_on(void)
|
force_int_on(void)
|
||||||
{
|
{
|
||||||
barrier();
|
barrier();
|
||||||
@ -10785,6 +10784,10 @@ preadfd(void)
|
|||||||
# endif
|
# endif
|
||||||
reinit_unicode_for_ash();
|
reinit_unicode_for_ash();
|
||||||
again:
|
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);
|
nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ);
|
||||||
if (nr == 0) {
|
if (nr == 0) {
|
||||||
/* ^C pressed, "convert" to SIGINT */
|
/* ^C pressed, "convert" to SIGINT */
|
||||||
|
@ -196,6 +196,7 @@ shell_builtin_read(struct builtin_read_params *params)
|
|||||||
*/
|
*/
|
||||||
errno = 0;
|
errno = 0;
|
||||||
pfd[0].events = POLLIN;
|
pfd[0].events = POLLIN;
|
||||||
|
//TODO race with a signal arriving just before the poll!
|
||||||
if (poll(pfd, 1, timeout) <= 0) {
|
if (poll(pfd, 1, timeout) <= 0) {
|
||||||
/* timed out, or EINTR */
|
/* timed out, or EINTR */
|
||||||
err = errno;
|
err = errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user