6749267: Signal handler should save/restore errno
authorhseigel
Tue, 19 Feb 2013 08:51:56 -0500
changeset 15743 f708934a12e7
parent 15742 b0ec3b170702
child 15745 fc43fd9458ce
6749267: Signal handler should save/restore errno Summary: Save errno before processing signal, then restore it. Reviewed-by: acorn, sspitsyn
hotspot/src/os/bsd/vm/os_bsd.cpp
hotspot/src/os/linux/vm/os_linux.cpp
hotspot/src/os/solaris/vm/os_solaris.cpp
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Tue Feb 19 08:51:56 2013 -0500
@@ -2887,7 +2887,9 @@
 
 void signalHandler(int sig, siginfo_t* info, void* uc) {
   assert(info != NULL && uc != NULL, "it must be old kernel");
+  int orig_errno = errno;  // Preserve errno value over signal handler.
   JVM_handle_bsd_signal(sig, info, uc, true);
+  errno = orig_errno;
 }
 
 
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Tue Feb 19 08:51:56 2013 -0500
@@ -3653,7 +3653,9 @@
 
 void signalHandler(int sig, siginfo_t* info, void* uc) {
   assert(info != NULL && uc != NULL, "it must be old kernel");
+  int orig_errno = errno;  // Preserve errno value over signal handler.
   JVM_handle_linux_signal(sig, info, uc, true);
+  errno = orig_errno;
 }
 
 
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Tue Feb 19 08:51:56 2013 -0500
@@ -4317,7 +4317,9 @@
 
 
 void signalHandler(int sig, siginfo_t* info, void* ucVoid) {
+  int orig_errno = errno;  // Preserve errno value over signal handler.
   JVM_handle_solaris_signal(sig, info, ucVoid, true);
+  errno = orig_errno;
 }
 
 /* Do not delete - if guarantee is ever removed,  a signal handler (even empty)