diff svr-chansession.c @ 893:860e3522f8fc

- Save errno in signal handlers - Use _exit() in segv handler
author Matt Johnston <matt@ucc.asn.au>
date Sat, 15 Feb 2014 21:13:57 +0800
parents aa689d140928
children 5daedffd0769
line wrap: on
line diff
--- a/svr-chansession.c	Fri Feb 14 23:18:45 2014 +0800
+++ b/svr-chansession.c	Sat Feb 15 21:13:57 2014 +0800
@@ -87,6 +87,8 @@
 	struct sigaction sa_chld;
 	struct exitinfo *exit = NULL;
 
+	const int saved_errno = errno;
+
 	TRACE(("enter sigchld handler"))
 	while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
 		TRACE(("sigchld handler: pid %d", pid))
@@ -140,6 +142,8 @@
 	sigemptyset(&sa_chld.sa_mask);
 	sigaction(SIGCHLD, &sa_chld, NULL);
 	TRACE(("leave sigchld handler"))
+
+	errno = saved_errno;
 }
 
 /* send the exit status or the signal causing termination for a session */