libxl: save/restore errno in SIGCHLD handler
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 11 Nov 2013 17:17:55 +0000 (17:17 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 12 Nov 2013 15:31:15 +0000 (15:31 +0000)
Without this, code interrupted by SIGCHLD may experience strange
values of errno.  (As far as I know this is not the cause of any
reported bugs.)

This fix should be backported in due course.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_fork.c

index 044ddad1397694647403fdbaf51fc4cda4ae939f..b6f0b2d034d3005032ccbe8b39e50eb7076ac5a1 100644 (file)
@@ -157,8 +157,10 @@ int libxl__carefd_fd(const libxl__carefd *cf)
 
 static void sigchld_handler(int signo)
 {
+    int esave = errno;
     int e = libxl__self_pipe_wakeup(sigchld_owner->sigchld_selfpipe[1]);
     assert(!e); /* errors are probably EBADF, very bad */
+    errno = esave;
 }
 
 static void sigchld_removehandler_core(void)