From 3d652087604ca1c6a66d9fa319645aeec1cf1b7b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 23 Aug 2015 03:30:46 +0200 Subject: signal handlers that return should not modify errno MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/macros.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/libmdsserver') diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h index 89db22f..f17da94 100644 --- a/src/libmdsserver/macros.h +++ b/src/libmdsserver/macros.h @@ -752,5 +752,22 @@ #endif +/** + * Normal signal handlers should place this macro + * at the top of the function + */ +#define SIGHANDLER_START \ + int sighandler_saved_errno = errno + + +/** + * Normal signal handlers should place this macro + * at the bottom of the function, or just before + * any `return` + */ +#define SIGHANDLER_END \ + (errno = sighandler_saved_errno) + + #endif -- cgit v1.2.3-70-g09d2