chiark / gitweb /
Save errno in signal handler
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Dec 2015 01:44:38 +0000 (01:44 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Dec 2015 01:44:38 +0000 (01:44 +0000)
statemc.c

index 04f0a1d..cb5139d 100644 (file)
--- a/statemc.c
+++ b/statemc.c
@@ -536,6 +536,7 @@ static void *sigarrived_event(oop_source *lp, int fd, oop_event e, void *u) {
 }
 
 static void sigarrived_handler(int signum) {
+  int esave = errno;
   static char x;
   switch (signum) {
   case SIGTERM:
@@ -546,6 +547,7 @@ static void sigarrived_handler(int signum) {
     abort();
   }
   write(signal_self_pipe[1],&x,1);
+  errno = esave;
 }
 
 void init_signals(void) {