Re: [hackers] [PATCH] [ubase] dd: Use sigaction(2) to obviate select(2)

From: Richard Ipsum <>
Date: Sun, 10 Sep 2017 11:55:53 +0100

On Sat, Sep 09, 2017 at 11:06:15PM -0700, Eric Pruitt wrote:
> By setting the SIGINT handler using sigaction(2), automatic retries of
> the splice(2) call can be disabled by not setting SA_RESTART. This makes
> it possible to use Ctrl+C even if standard input is a terminal.
> ---
> +static void
> +sig_int(int unused_1, siginfo_t *unused_2, void *unused_3)
> +{
> + (void) unused_1;
> + (void) unused_2;
> + (void) unused_3;
> + fprintf(stderr, "SIGINT! Aborting ...\n");

This isn't a comment on this patch exactly, since this call
exists in the existing handler, but unless I'm missing something about
the way you're doing this it isn't safe to call fprintf in a signal
handler since your signal may be interrupting an fprintf call itself,
and since the data structures for stdio aren't reentrant, things will
get messy.

Received on Sun Sep 10 2017 - 12:55:53 CEST

This archive was generated by hypermail 2.3.0 : Sun Sep 10 2017 - 13:00:25 CEST