From: Simon McVittie <smcv@collabora.com>
Date: Wed, 27 Sep 2017 13:56:34 +0100
Subject: [PATCH 3/4] Make sure non-aborting signal handlers save and restore
errno
If an async signal interrupts some function, we can have this
anti-pattern:
/* in normal code */
result = some_syscall (); /* fails, e.g. errno = EINVAL */
/* interrupted by async signal handler */
write (...); /* fails, e.g. errno = ENOBUFS */
/* back to normal code */
if (errno == EINVAL) /* problem! it should be but it isn't */
The solution is for signal handlers to save and restore errno.
This is unnecessary for signal handlers that can't touch errno (like
the one in dbus-launch that just sets a flag), and for signal handlers
that never return (like the one in test-utils-glib for timeouts).
Signed-off-by: Simon McVittie <smcv@collabora.com>