Giuseppe Scrivano wrote:
> Hello,
> 
> do you have suggestions on this patch?  It replaces any `signal' with
> `sigaction'.

[snip]

> diff --git a/src/timeout.c b/src/timeout.c
> index 8b506f0..6ef7218 100644
> --- a/src/timeout.c
> +++ b/src/timeout.c
> @@ -278,8 +278,6 @@ main (int argc, char **argv)
>    /* Setup handlers before fork() so that we
>       handle any signals caused by child, without races.  */
>    install_signal_handlers ();
> -  signal (SIGTTIN, SIG_IGN);    /* don't sTop if background child needs tty. 
>  */
> -  signal (SIGTTOU, SIG_IGN);    /* don't sTop if background child needs tty. 
>  */

Moving these after the fork() introduces a race
I think as per the comment.

> +      struct sigaction sa_ignore;
> +
> +      memset (&sa_ignore, 0, sizeof sa_ignore);

Note since C90 this is equivalent to memset(0):
struct sigaction sa_ignore = {0,};

> +      sigemptyset (&sa_ignore.sa_mask);
> +      sa_ignore.sa_handler = SIG_IGN;
> +
> +      sigaction (SIGTTIN, &sa_ignore, NULL);     /* don't sTop if background 
> child needs tty.  */
> +      sigaction (SIGTTOU, &sa_ignore, NULL);    /* don't sTop if background 
> child needs tty.  */

As I mentioned previously it might be better
for us to define our own function that calls sigaction,
but has the same interface as signal() as this is
a much cleaner interface and usually all that's required.

thanks,
Pádraig.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to