changeset 4173:5cd2fac2ae70

6749267: Signal handler should save/restore errno Summary: Save errno before processing signal, then restore it. Reviewed-by: acorn, sspitsyn
author hseigel
date Tue, 19 Feb 2013 08:51:56 -0500
parents b5e3ec9c69fa
children 1048edb5434a
files src/os/bsd/vm/os_bsd.cpp src/os/linux/vm/os_linux.cpp src/os/solaris/vm/os_solaris.cpp
diffstat 3 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/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/src/os/linux/vm/os_linux.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/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/src/os/solaris/vm/os_solaris.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/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)