mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 16:50:58 +01:00
36022 fix bug that some loop constructs could not be interrupted, revise signal queueing
There are two underlying ideas here: (1) Keeping signals queued around anything that's doing memory management (including push/pop of the heap) has become crucial. (2) Anytime the shell is going to run a command, be it buitin or external, it must be both safe and necessary to process any queued signals, so that the apparent order of signal arrival and command execution is preserved.
This commit is contained in:
parent
ce12868837
commit
9958684574
7 changed files with 119 additions and 14 deletions
12
Src/input.c
12
Src/input.c
|
|
@ -141,16 +141,19 @@ shingetline(void)
|
|||
int c;
|
||||
char buf[BUFSIZ];
|
||||
char *p;
|
||||
int q = queue_signal_level();
|
||||
|
||||
p = buf;
|
||||
winch_unblock();
|
||||
for (;;) {
|
||||
winch_unblock();
|
||||
dont_queue_signals();
|
||||
do {
|
||||
errno = 0;
|
||||
c = fgetc(bshin);
|
||||
} while (c < 0 && errno == EINTR);
|
||||
if (c < 0 || c == '\n') {
|
||||
winch_block();
|
||||
restore_queue_signals(q);
|
||||
if (c == '\n')
|
||||
*p++ = '\n';
|
||||
if (p > buf) {
|
||||
|
|
@ -167,12 +170,13 @@ shingetline(void)
|
|||
*p++ = c;
|
||||
if (p >= buf + BUFSIZ - 1) {
|
||||
winch_block();
|
||||
queue_signals();
|
||||
line = zrealloc(line, ll + (p - buf) + 1);
|
||||
memcpy(line + ll, buf, p - buf);
|
||||
ll += p - buf;
|
||||
line[ll] = '\0';
|
||||
p = buf;
|
||||
winch_unblock();
|
||||
unqueue_signals();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -377,6 +381,8 @@ inputline(void)
|
|||
static void
|
||||
inputsetline(char *str, int flags)
|
||||
{
|
||||
queue_signals();
|
||||
|
||||
if ((inbufflags & INP_FREE) && inbuf) {
|
||||
free(inbuf);
|
||||
}
|
||||
|
|
@ -394,6 +400,8 @@ inputsetline(char *str, int flags)
|
|||
else
|
||||
inbufct = inbufleft;
|
||||
inbufflags = flags;
|
||||
|
||||
unqueue_signals();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue