Bug 103010: Be more careful with errno in async signal handlers - Simon McVittie <smcv@collabora.com> - 9/27/2017 Back to Bug | Your Reviews | Help
Attachment 134503: Make sure non-aborting signal handlers save and restore errno - Simon McVittie <smcv@collabora.com> - 9/27/2017 (View )

Show Quick Help

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>
<Overall Comment>
Previous Reviews
Philip Withnall <bugzilla@tecnocode.co.uk>
9/27/2017
-----------------------------------------------------------------
++
dbus/dbus-spawn.c
1145 
1146 again:
1147 if (write (babysit_sigchld_pipe, &b, 1) <= 0)
1148 if (errno == EINTR)
1149 goto again;
Christ, this is a horrific way of doing a loop. However, ENOTYOURPROBLEM.
Powered by Splinter

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.