From: Frank Lahm Date: Thu, 22 Nov 2012 08:58:02 +0000 (+0100) Subject: Use sigaction() instead of signal() for ignoring SIGPIPE X-Git-Url: https://arthur.barton.de/gitweb/?p=netatalk.git;a=commitdiff_plain;h=7c87a58e70aab8eb2789f49eb4cd7c28f7df5bbc Use sigaction() instead of signal() for ignoring SIGPIPE Move the code to ignore SIGPIPE from the DSI sesssion setup stage to the main signal handling code in main() and avoid the use of deprecated signal() function and use sigaction. --- diff --git a/etc/afpd/main.c b/etc/afpd/main.c index e89d0a2e..afbd90e0 100644 --- a/etc/afpd/main.c +++ b/etc/afpd/main.c @@ -253,6 +253,13 @@ int main(int ac, char **av) afp_exit(EXITERR_SYS); } #endif + + sv.sa_handler = SIG_IGN; + sigemptyset( &sv.sa_mask ); + if (sigaction(SIGPIPE, &sv, NULL ) < 0 ) { + LOG(log_error, logtype_afpd, "main: sigaction: %s", strerror(errno) ); + afp_exit(EXITERR_SYS); + } sv.sa_handler = afp_goaway; /* handler for all sigs */ diff --git a/libatalk/dsi/dsi_getsess.c b/libatalk/dsi/dsi_getsess.c index 001279cd..d5b855a8 100644 --- a/libatalk/dsi/dsi_getsess.c +++ b/libatalk/dsi/dsi_getsess.c @@ -121,7 +121,6 @@ int dsi_getsession(DSI *dsi, server_child *serv_children, int tickleval, afp_chi /* set up the tickle timer */ dsi->timer.it_interval.tv_sec = dsi->timer.it_value.tv_sec = tickleval; dsi->timer.it_interval.tv_usec = dsi->timer.it_value.tv_usec = 0; - signal(SIGPIPE, SIG_IGN); /* we catch these ourselves */ dsi_opensession(dsi); *childp = NULL; return 0;