diff --git a/core/Logger.cc b/core/Logger.cc index 17d5c74d500004831efb7e9e9094bdb6c75a914f..241f48b125f4f0a1b58e420d6bfffd072a1b7dad 100644 --- a/core/Logger.cc +++ b/core/Logger.cc @@ -458,6 +458,11 @@ char *TTCN_Logger::mputstr_timestamp(char *str, time_t tv_sec = tv->tv_sec; struct tm *lt = localtime(&tv_sec); if (lt == NULL) fatal_error("localtime() call failed."); + if (errno != 0) { + // HACK: 'localtime' may set the 'errno' on some systems (even though it + // succeeds); make sure this doesn't affect other code + errno = 0; + } if (p_timestamp_format == TIMESTAMP_TIME) { str = mputprintf(str, "%02d:%02d:%02d.%06ld", lt->tm_hour, lt->tm_min, lt->tm_sec, tv->tv_usec); diff --git a/core/Runtime.cc b/core/Runtime.cc index a466d5cb98cc5e8d0605d9db8aae23809b503abc..8b8a95fd1e0eb03f93cd4abcab06cd6fb0d4f1cc 100644 --- a/core/Runtime.cc +++ b/core/Runtime.cc @@ -3019,7 +3019,6 @@ void TTCN_Runtime::wait_terminated_processes() // this function might be called from TCs too while returning from // TTCN_Communication::process_all_messages_hc() after fork() if (!is_hc()) return; - errno = 0; for ( ; ; ) { int statuscode; #ifdef __clang__ @@ -3028,6 +3027,7 @@ void TTCN_Runtime::wait_terminated_processes() struct rusage r_usage = {{0,0},{0,0},0,0,0,0,0,0,0,0,0,0,0,0,0,0}; #endif + errno = 0; #ifdef INTERIX pid_t child_pid = waitpid(-1, &statuscode, WNOHANG); getrusage(RUSAGE_CHILDREN, &r_usage);