[Libevent-users] [PATCH] signal.c, evsignal.h: properly save/restore previous signal handlers and fix memory stomp

Scott Lamb slamb at slamb.org
Fri Nov 9 19:03:46 EST 2007


Christopher Layne wrote:
> +	/* save previous handler setup */
> +	if (sigaction(evsignal, NULL, sig->sa_old[evsignal]) == -1
> +		|| sigaction(evsignal, &sa, NULL) == -1)

Not worth changing unless you're redoing the patch anyway, but is there 
some reason you aren't doing this in a single call? I.e.,

     if (sigaction(evsignal, &sa, sig->sa_old[evsignal]) == -1) {

...

> -	if (!base->sig.ev_signal_added) {
> -		base->sig.ev_signal_added = 1;
> -		event_add(&base->sig.ev_signal, NULL);
> +	if (!sig->ev_signal_added) {
> +		sig->ev_signal_added = 1;
> +		event_add(&sig->ev_signal, NULL);
>  	}

There's a bug here (that predates your change): this code should handle 
event_add() failure. (E.g., epoll_ctl() returning ENOMEM.)


More information about the Libevent-users mailing list