bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Replacement for the sigs_to_ignore hack in timeout.c


From: Pádraig Brady
Subject: Re: [PATCH] Replacement for the sigs_to_ignore hack in timeout.c
Date: Sat, 11 Oct 2008 00:31:04 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]