diff --git a/tdeioslave/imap4/imap4.cc b/tdeioslave/imap4/imap4.cc index 8ce20769..87a6b9c4 100644 --- a/tdeioslave/imap4/imap4.cc +++ b/tdeioslave/imap4/imap4.cc @@ -71,6 +71,7 @@ imap://server/folder/ #include #include #include +#include #ifdef HAVE_LIBSASL2 extern "C" { @@ -147,6 +148,10 @@ kdemain (int argc, char **argv) void sigchld_handler (int signo) { + // A signal handler that calls for example waitpid has to save errno + // before and restore it afterwards. + // (cf. https://www.securecoding.cert.org/confluence/display/cplusplus/ERR32-CPP.+Do+not+rely+on+indeterminate+values+of+errno) + const int save_errno = errno; int pid, status; while (signo == SIGCHLD) @@ -158,9 +163,11 @@ sigchld_handler (int signo) // the signal occurred ( BSD handles it different, but it should do // no harm ). signal (SIGCHLD, sigchld_handler); - return; + break; } } + + errno = save_errno; } IMAP4Protocol::IMAP4Protocol (const TQCString & pool, const TQCString & app, bool isSSL):TCPSlaveBase ((isSSL ? 993 : 143),