Re: [PATCH] x86_64: fix delayed signals

From: Linus Torvalds
Date: Sun Jul 13 2008 - 15:10:02 EST




On Sun, 13 Jul 2008, Andi Kleen wrote:
>
> While the bit about color ls (which I use here) catching signals was
> also interesting I wouldn't expect the color ls to take longer to
> process Ctrl-C even if it hits user space because it shouldn't
> do anything block here (unless the terminal is in flow control,
> but is unlikely)

I didn't take a look at the source, but I literally think that the 'ls'
SIGINT handler is something like

static void sigint(int signr)
{
exit_with_sigint = 1;
}

and then in the output routine it does a

if (exit_with_sigint) {
signal(SIGINT, SIG_DFL);
kill(-1, SIGINT);
}

at the end because that's the only thing that explains that it always
exits after printing the _first_ line of output (ignoring the header - it
obviously doesn't have that "if (exit_with_sigint)" test in that
code-path).

Sad. Horrible crap. It means that it totally disables the kernels ability
to make fatal signals break out of disk wait etc. It's also totally
_unnecessary_, because 'ls' shouldn't even bother to block signals until
just before it starts doing the printout.

Oh well. You can't expect too much of user level programmers.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/