[Date Prev][Date Next]
Re: (ITS#6037) errno in signal handlers
> Full_Name: Hallvard B Furuseth
> Version: HEAD, RE24
> Submission from: (NULL) (184.108.40.206)
> Submitted by: hallvard
> Signal handlers slapd/daemon.c:slap_sig_shutdown()/slap_sig_wake() need
> to save/restore errno, since they call functions that can modify errno.
> And/or possibly they need sock_errno() - sock_errset() from ac/socket.h,
> since they use tcp_write()? I don't know if that's safe inside signal
> handlers, or if Windows itself saves/restores this code around signal
Windows doesn't really have signals in the first place. SIGTERM/SIGINT are
simulated by the C runtime library, none of the other signals are really
supported... All of the "support" is synchronous only - can only be invoked by
raise(). I don't think there's any issue here.
(An exception - I wrote a patch for the MSYS 1.11 runtime to propagate
SIGINT/SIGTERM to other processes. The patch only works on win32, not win64
because I never got a decent win64 build environment working... But if you're
using MSYS, it is possible to send these signals to a running slapd and have
it shutdown cleanly. Otherwise, signals don't really exist for native Windows
> slapd/main.c:wait4child() can loop forever after EINTR, since it checks
> for errno even when the waitpid returns 0. I don't know if there is
> a good reason it does that. Some of the commits have my name on them
> but I think I copied it from elsewhere.
> Anyway, I'm doing the minimal changes now: save/restore errno, and
> set errno=0 in each loop iteration instead of before the loop.
> Anyone with better ideas can take it from there.
Good enough. Closing this ITS.
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/