Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Interrupting globs (Re: Something rotten in tar completion)



On Mon, Dec 8, 2014 at 12:18 PM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Sun, 7 Dec 2014 17:19:20 +0000
> Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
>> diff --git a/Src/jobs.c b/Src/jobs.c
>> index 6e47e5e..3c2a21a 100644
>> --- a/Src/jobs.c
>> +++ b/Src/jobs.c
>> @@ -1444,7 +1444,19 @@ zwaitjob(int job, int wait_cmd)
>>               restore_queue_signals(q);
>>               return 128 + last_signal;
>>           }
>> -         errflag &= ~ERRFLAG_ERROR;
>> +/*...*/
>> +           errflag = 0; */
>> +
>>           if (subsh) {
>>               killjb(jn, SIGCONT);
>>               jn->stat &= ~STAT_STOPPED;
>
> Aha!  Spotted when trying out TRY_BLOCK_INTERRUPT.
>
> I only switched ERRFLAG_ERROR to ERRFLAG_INT when the shell *itself*
> gets the interrupt.  The case here, and in the test I was running, is
> where we propagate a SIGINT detected by WTERMSIGing (er, that's a verb,
> right?) a process that exited because it received the ^C (and the shell
> wasn't part of the foreground process group).
>
> The following patch (applicable to the interrupt_abort branch) makes
> TRY_BLOCK_INTERRUPT do sensible things in that case.  Needless to say I
> haven't dared back off the patch quoted above again...
>
> By the way, the cases below already handle SIGINT and SIGQUIT in
> parallel, which suggest the code I added to do this for mimicking signals
> on return from a trap is at least consistent.

(Since this is maybe a little known feature of git, :/foo is the first
reachable commit on any branch with the string foo in the commit name,
you can literally say
git revert :/'this is a very good solution with no drawbacks'
).

Good news and bad news, with this latest patch, I can revert :/'Put
back commenting' and still ctrl-c out of cd ../linux in one go, BUT,
when I do, with or without the revert, it immediately puts me back at
the prompt without executing preexec().

Test case for you guys:
% zsh -f
% precmd() echo yes
% sleep 2; echo no
^C
yes

With :/'Ensure propagation' and :/'Put back' (eg, current tip of
interrupt_abort), I get neither printed.

Reverting :/'Put back' still gets me neither (ie, it makes no
difference, which I guess is the goal of this, so yay?).

With both reverted, I get what I originally reported (obviously)
^C
no
yes

With only :/'Ensure propagation' reverted (eg, at the previous tip), I get
^C
yes

So I guess some other place needs to clear interrupts as well, or the
"return to commandline" clear should be before precmd being called?
(If that's nonsense it's because I haven't looked at the code for that
at all).

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author